ContributionsMost RecentMost LikesSolutionsRe: Selenium on Linux Collector to execute synthetic webchecks Thanks for the datasources; they confirmed what I was doing! And then, just to finalize this, as my previous script was indeed a very crude and hastily comprised. I had to abandon all Asserts (including softAsserts),so a better generalized version below having two datapoints: FailedStep and GeneralSuccess (not really needed, but just for clarity). Two graphs as well having the same ones where FailedStep has vertical label description as "ZeroIsGood" and GeneralSuccess has "OneIsGood". Of course alert thresholdsset respectively. This quite probably fits my needs nicely when cloning and amending to multiple different tests. (One development step would still be to get rid of the "--no-sandbox" as it is a security risk to run chromedriver as root.) importorg.openqa.selenium.By; importorg.openqa.selenium.WebDriver; importorg.openqa.selenium.chrome.ChromeDriver; importorg.openqa.selenium.chrome.ChromeOptions; importorg.openqa.selenium.WebElement; importjava.util.*; importjava.net.MalformedURLException; importjava.net.URL; ChromeOptionschromeOptions=newChromeOptions(); chromeOptions.addArguments("--no-sandbox"); chromeOptions.addArguments("--headless"); WebDriverdriver=newChromeDriver(options=chromeOptions); ///////STEP1 try{ driver.get("http://juhani.exdecfinland.org/~tforsell/home.html"); if(driver.getTitle().contains("404"))//Onlywaytocatchpagenotfound(https://stackoverflow.com/questions/17657037/catching-a-404-error-with-selenium) {println"GeneralSuccess=0";println"FailedStep=1";driver.quit();return0;} }catch(Exceptionex){println"GeneralSuccess=0";println"FailedStep=1";driver.quit();return0;} ///////STEP2 try{ driver.findElement(By.cssSelector("a:nth-child(4)>img")).click();//Clickthemotorbikeimageintheright frame if(driver.getTitle().contains("404"))//Onlywaytocatchpagenotfound(https://stackoverflow.com/questions/17657037/catching-a-404-error-with-selenium) {println"GeneralSuccess=0";println"FailedStep=2";driver.quit();return0;} }catch(Exceptionex){println"GeneralSuccess=0";println"FailedStep=2";driver.quit();return0;} ///////STEP3 try{ if(!driver.findElement(By.cssSelector("h2:nth-child(56)")).getText().contains("Saksanreissu-Germanytrip2005")) {println"GeneralSuccess=0";println"FailedStep=3";driver.quit();return0;} }catch(Exceptionex){println"GeneralSuccess=0";println"FailedStep=3";driver.quit();return0;} println"GeneralSuccess=1";println"FailedStep=0";driver.quit();return0; Re: Selenium on Linux Collector to execute synthetic webchecks Thanks Jake. Your post was quite timely with my intentions to try Selenium with LogicMonitor and very much helped get me started (although I used CentOS collector machine, but still the bash-script gave the right direction of course!? Those DataSources seemed to be private, so I could not load them, so I created one myself (included below; possibly very bad version, but it works ?). In order to check textFields in the target web site, I also added two more libraries in addition to the selenium-server-standalone.jar: wrapper.java.classpath.115=../custom/selenium-server-standalone.jar wrapper.java.classpath.116=../custom/hamcrest-2.2.jar wrapper.java.classpath.117=../custom/junit-4.13.jar And here is my example Groovy-script just to help others (maybe): import com.santaba.agent.groovyapi.expect.Expect; import com.santaba.agent.groovyapi.snmp.Snmp; import com.santaba.agent.groovyapi.http.*; import com.santaba.agent.groovyapi.jmx.*; import org.xbill.DNS.*; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; //import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Alert; import org.openqa.selenium.Keys; import java.util.*; import java.net.MalformedURLException; import java.net.URL; ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--no-sandbox"); //chromeOptions.addArguments("--remote-debugging-port=9222"); //chromeOptions.addArguments("--disable-dev-shm-usage"); //chromeOptions.addArguments("--disable-gpu"); chromeOptions.addArguments("--headless"); WebDriver driver = new ChromeDriver(options=chromeOptions); driver.get("http://juhani.exdecfinland.org/~tforsell/home.html"); // driver.manage().window().setSize(new Dimension(1321, 916)); driver.findElement(By.cssSelector("a:nth-child(4) > img")).click(); assertThat(driver.findElement(By.cssSelector("h2:nth-child(56)")).getText(), is("Saksan reissu -Germany trip 2005")); driver.close(); driver.quit(); println("TeijoScriptStatus=Success");
Top ContributionsRe: Selenium on Linux Collector to execute synthetic webchecksRe: Selenium on Linux Collector to execute synthetic webchecks