Created
June 13, 2014 17:46
-
-
Save mwacc/055067d82ba17362fdee to your computer and use it in GitHub Desktop.
example of groovy script + selenium webdriver (maven artefact is loaded by anotation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group="org.seleniumhq.selenium", module="selenium-java", version="2.42.2") | |
import org.openqa.selenium.*; | |
import org.openqa.selenium.chrome.*; | |
System.setProperty("webdriver.chrome.driver", "/Users/kostya/Downloads/chromedriver"); | |
ChromeOptions chromeOptions = new ChromeOptions(); | |
chromeOptions.addArguments("--verbose", "--ignore-certificate-errors"); | |
WebDriver driver = new ChromeDriver(); | |
driver.get("http://auto.ria.com/?target=search&event=big&city=&state=5&category_id=1&marka=75&model=663¤cy=1&page=0"); | |
List<WebElement> advs = driver.findElements(By.cssSelector("div.content-bar")); | |
for(WebElement e : advs) { | |
try { | |
WebElement header = e.findElement(By.cssSelector("h3 > a")) | |
println header.getText(); | |
} catch(all) { } | |
} | |
driver.close(); | |
driver.quit(); |
@havryliuk @sanjeets Java code is a valid subset of Groovy, so everything is fine here and as for 2015 was a good way to execute some Java code in a-al script way
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is in java not groovy
whats going on?