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 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 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 spring-boot by spring-projects.
the class UserVehicleControllerSeleniumTests method getVehicleWhenRequestingTextShouldReturnMakeAndModel.
@Test
public void getVehicleWhenRequestingTextShouldReturnMakeAndModel() throws Exception {
given(this.userVehicleService.getVehicleDetails("sboot")).willReturn(new VehicleDetails("Honda", "Civic"));
this.webDriver.get("/sboot/vehicle.html");
WebElement element = this.webDriver.findElement(By.tagName("h1"));
assertThat(element.getText()).isEqualTo("Honda Civic");
}
use of org.openqa.selenium.WebElement in project spring-boot by spring-projects.
the class WebMvcTestWebDriverIntegrationTests method shouldAutoConfigureWebClient.
@Test
public void shouldAutoConfigureWebClient() throws Exception {
this.webDriver.get("/html");
WebElement element = this.webDriver.findElement(By.tagName("body"));
assertThat(element.getText()).isEqualTo("Hello");
WebMvcTestWebDriverIntegrationTests.previousWebDriver = this.webDriver;
}
Aggregations