use of org.openqa.selenium.WebElement in project webmagic by code4craft.
the class SeleniumTest method testSelenium.
@Ignore("need chrome driver")
@Test
public void testSelenium() {
System.getProperties().setProperty("webdriver.chrome.driver", "/Users/yihua/Downloads/chromedriver");
Map<String, Object> contentSettings = new HashMap<String, Object>();
contentSettings.put("images", 2);
Map<String, Object> preferences = new HashMap<String, Object>();
preferences.put("profile.default_content_settings", contentSettings);
DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.prefs", preferences);
caps.setCapability("chrome.switches", Arrays.asList("--user-data-dir=/Users/yihua/temp/chrome"));
WebDriver webDriver = new ChromeDriver(caps);
webDriver.get("http://huaban.com/");
WebElement webElement = webDriver.findElement(By.xpath("/html"));
System.out.println(webElement.getAttribute("outerHTML"));
webDriver.close();
}
use of org.openqa.selenium.WebElement in project head by mifos.
the class SeleniumTest method testSearchMifosOnGoogle.
@Test
public void testSearchMifosOnGoogle() throws Exception {
WebDriver wd = new FirefoxDriver();
try {
wd.get("http://www.google.com");
WebElement element = wd.findElement(By.name("q"));
element.sendKeys("Mifos");
element.submit();
} finally {
wd.quit();
}
}
use of org.openqa.selenium.WebElement in project sonarqube by SonarSource.
the class ByCssSelectorOrByNameOrById method findElement.
@Override
public WebElement findElement(SearchContext context) {
WebElement element;
if (validCssSelector(selector)) {
element = ((FindsByCssSelector) context).findElementByCssSelector(quoteCss(selector));
if (element != null) {
return element;
}
}
element = ((FindsByName) context).findElementByName(selector);
if (element != null) {
return element;
}
element = ((FindsById) context).findElementById(selector);
if (element != null) {
return element;
}
return null;
}
use of org.openqa.selenium.WebElement in project cucumber-jvm by cucumber.
the class RentACarSupport method getAvailableNumberOfCars.
public int getAvailableNumberOfCars() {
WebDriver driver = new HtmlUnitDriver();
try {
driver.get("http://localhost:9878/rentit/available");
WebElement availableCars = driver.findElement(By.id("availableCars"));
String availableCarsString = availableCars.getText();
return Integer.parseInt(availableCarsString);
} finally {
driver.close();
}
}
use of org.openqa.selenium.WebElement in project cucumber-jvm by cucumber.
the class RentACarSupport method rentACar.
public void rentACar() {
WebDriver driver = new HtmlUnitDriver();
try {
driver.get("http://localhost:9878/rentit/rent");
WebElement rentButton = driver.findElement(By.id("rentButton"));
rentButton.click();
} finally {
driver.close();
}
}
Aggregations