List of usage examples for org.openqa.selenium.remote RemoteWebDriver findElement
@Override
public WebElement findElement(By by)
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void verifyTable(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String[] path = params.get("target").split("\\."); WebElement webElement = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(path[0])) .findElements(By.tagName("tr")).get(Integer.parseInt(path[1])).findElements(By.tagName("td")) .get(Integer.parseInt(path[2])); String text = webElement.getText(); if (!text.equals(params.get("value"))) state.setFailed();/*from w ww . j av a 2 s .c o m*/ }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void verifyElementPresent(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { try {//from w w w.j a v a 2s . c om WebElement webElement = remoteWebDriver .findElement(CommandMappings.detectTargetMethod(params.get("target"))); } catch (org.openqa.selenium.NoSuchElementException ex) { state.setFailed(); } }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void storeText(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String value = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getText();/* w w w . j a v a 2s.c o m*/ state.setVariable(params.get("text"), value); }
From source file:org.openqa.runner.Commands.java
License:Apache License
public static void storeValue(RemoteWebDriver remoteWebDriver, State state, Map<String, String> params) { String value = remoteWebDriver.findElement(CommandMappings.detectTargetMethod(params.get("target"))) .getAttribute("value"); state.setVariable(params.get("value"), value); }
From source file:org.uiautomation.ios.Demo.java
License:Apache License
public static void main2(String[] args) throws Exception { String[] a = { "-port", "4445", "-host", "localhost", "-aut", SampleApps.getUICatalogFile(), "-aut", SampleApps.getUICatalogIpad(), "-aut", "/Users/freynaud/eBay3.1_19.app" }; IOSServerConfiguration config = IOSServerConfiguration.create(a); IOSServer server = new IOSServer(config); server.start();/*from ww w . ja v a 2 s . c om*/ IOSCapabilities cap = IOSCapabilities.iphone("eBay"); cap.setCapability(IOSCapabilities.SIMULATOR, true); if (useQA) { cap.setCapability(IOSCapabilities.IOS_SWITCHES, Arrays.asList(new String[] { "-e", "useQA", "YES" })); } RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4445/wd/hub"), cap); WebElement agree = driver.findElement(By.name("Agree")); agree.click(); WebElement searchField = driver.findElement(By.linkText("value=Search eBay")); searchField.sendKeys("ihpone5"); WebElement search = driver.findElement(By.xpath("//UIAButton[@label='search']")); search.click(); driver.quit(); server.stop(); }
From source file:org.uiautomation.ios.Demo.java
License:Apache License
public static void main(String[] args) throws Exception { String[] a = { "-port", "5555", "-host", "127.0.0.1", //"-aut", SampleApps.getUICatalogFile(), //"-aut", SampleApps.getUICatalogIpad(), //"-beta", "-folder", "applications", "-simulators", "-hub", "http://127.0.0.1:4444/grid/register" }; IOSServerConfiguration config = IOSServerConfiguration.create(a); IOSServer server = new IOSServer(config); server.start();//from w w w.j av a2 s . c o m IOSCapabilities cap = IOSCapabilities.iphone("eBay"); cap.setCapability(IOSCapabilities.IOS_SWITCHES, Arrays.asList(new String[] { "-e", "useQA", "YES" })); RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap); try { driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS); WebElement agree = driver.findElement(By.name("Agree")); agree.click(); //driver.switchTo().alert().dismiss(); WebElement signInButton = driver.findElement(By.xpath("//UIAButton[@name='Sign In']")); signInButton.click(); WebElement user = driver.findElement(By.xpath("//UIATextField[@value='User ID or email']")); user.sendKeys(userId); WebElement pass = driver.findElement(By.xpath("//UIASecureTextField[@value='Password']")); pass.sendKeys(password); WebElement element4 = driver.findElement(By.xpath("//UIAButton[@name='Done']")); element4.click(); Thread.sleep(2000); boolean cartDown = false; // navigate String itemId = "220003725262"; if (cartDown) { WebElement search = driver.findElement(By.xpath("//UIAButton[@name='Search']")); search.click(); //validate WebElement element1 = driver.findElement(By.xpath("//UIASearchBar[@value='Search Watching']")); element1.sendKeys(itemId); // check it's there. WebElement result = driver.findElement(By.className("UIATableCell")); System.out.println(result.getAttribute("name")); } else { WebElement basket = driver.findElement(By.xpath("//UIAButton[@name='Basket, 1 item']")); //By.xpath("//UIAButton[matches(@name,l10n('ItemCountFormatStringPlural'))]")); //ItemCountFormatStringSingular basket.click(); //WebElement firstItem = driver.findElement(By.xpath("//UIATableCell[2]")); //firstItem.click(); WebElement search = driver.findElement(By.name("Checkout")); search.click(); } // watch WebElement paypal = driver.findElement(By.name("Please login to your account")); paypal.click(); while (driver.getWindowHandles().size() != 3) { Thread.sleep(1000); } WebElement email = null; while (email == null) { try { driver.switchTo().window("Web_3"); email = driver.findElement(By.id("email")); } catch (NoSuchElementException e) { Thread.sleep(1000); System.out.println("not found"); } } driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); driver.findElement(By.cssSelector(".resetter")).click(); email.sendKeys("ppbuild-1920977828325914@paypal.com"); WebElement password = driver.findElement(By.id("password")); password.sendKeys("11111111"); WebElement login = driver.findElement(By.id("login")); login.click(); Thread.sleep(30000); } finally { driver.quit(); server.stop(); } }
From source file:org.uiautomation.ios.Demo.java
License:Apache License
public static void main3(String[] args) throws Exception { String[] a = { "-port", "4444", "-host", "localhost", "-aut", "/Users/freynaud/PayPal Here.app" }; IOSServerConfiguration config = IOSServerConfiguration.create(a); IOSServer server = new IOSServer(config); server.start();//from w w w . j a v a 2 s . com IOSCapabilities cap = IOSCapabilities.iphone("PayPal Here"); cap.setCapability(IOSCapabilities.SIMULATOR, true); RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap); WebElement agree = driver.findElement(By.name("Sign Up for PayPal Here")); agree.click(); driver.quit(); server.stop(); }
From source file:org.uiautomation.ios.selenium.Demo.java
License:Apache License
public static void main3(String[] args) throws Exception { DesiredCapabilities safari = IOSCapabilities.ipad("Safari"); RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), safari); driver.get("http://ebay.co.uk"); ((Rotatable) new Augmenter().augment(driver)).rotate(ScreenOrientation.LANDSCAPE); WebElement search = driver.findElement(By.id("srchDv")); search.sendKeys("ipod"); search.submit();/* w w w . j av a2 s . c o m*/ waitFor(pageTitleToBe(driver, "ipod | eBay Mobile Web")); driver.quit(); }
From source file:org.uiautomation.ios.selenium.Demo.java
License:Apache License
public static void main(String[] args) throws Exception { IOSCapabilities catalog = IOSCapabilities.iphone("UICatalog"); RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), catalog); // by default, the app starts in native mode. WebElement web = driver.findElement(By.xpath("//UIATableCell[contains(@name,'Web')]")); web.click();//from ww w. j a va 2s .com // now that a webview is displayed, switch to web mode. driver.switchTo().window("Web"); // and select items using natural web selectors. final By cssSelector = By.cssSelector("a[href='http://store.apple.com/']"); // reuse whatever contrust your webdriver tests are using. WebElement el = waitFor(elementToExist(driver, cssSelector)); Assert.assertEquals(el.getAttribute("href"), "http://store.apple.com/"); driver.quit(); }
From source file:org.uiautomation.ios.selenium.Demo.java
License:Apache License
public static void main2(String[] args) throws Exception { DesiredCapabilities safari = IOSCapabilities.iphone("Safari"); RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), safari); driver.get("http://hp.mobileweb.ebay.co.uk/home"); WebElement search = driver.findElement(By.id("srchDv")); search.sendKeys("ipod"); search.submit();/*from w w w . j a va2 s .co m*/ waitFor(pageTitleToBe(driver, "ipod | eBay Mobile Web")); driver.quit(); }