Search in sources :

Example 11 with WebElement

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();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) WebElement(org.openqa.selenium.WebElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with WebElement

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;
}
Also used : WebElement(org.openqa.selenium.WebElement)

Example 13 with WebElement

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();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 14 with WebElement

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");
}
Also used : WebElement(org.openqa.selenium.WebElement) VehicleDetails(sample.test.service.VehicleDetails) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 15 with WebElement

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;
}
Also used : WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Aggregations

WebElement (org.openqa.selenium.WebElement)520 Test (org.junit.Test)96 WebDriver (org.openqa.selenium.WebDriver)85 PublicAtsApi (com.axway.ats.common.PublicAtsApi)57 Actions (org.openqa.selenium.interactions.Actions)55 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)46 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 By (org.openqa.selenium.By)36 URL (java.net.URL)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)34 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)30 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)21 NoSuchElementException (org.openqa.selenium.NoSuchElementException)21 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)19 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)13 Select (org.openqa.selenium.support.ui.Select)13 TimeoutException (org.openqa.selenium.TimeoutException)12 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)11 List (java.util.List)10