List of usage examples for org.openqa.selenium By className
public static By className(String className)
From source file:com.mroza.seleniumTests.MrozaViewPage.java
License:Open Source License
protected void clickDialogButton(String buttonName) { WebElement dialog = getVisibleDialogBox(); WebElement buttonPanel = dialog.findElement(By.className("ui-dialog-buttonpane")); List<WebElement> buttons = buttonPanel.findElements(By.tagName("button")); for (WebElement button : buttons) { List<WebElement> spanElements = button.findElements(By.tagName("span")); if (spanElements.get(1).getText().equals(buttonName)) { Actions actions = new Actions(driver); actions.moveToElement(button).click().perform(); SeleniumWaiter.waitForJQueryAndPrimeFaces(driver); break; }//from w w w .j av a2s .c om } }
From source file:com.mroza.seleniumTests.MrozaViewPage.java
License:Open Source License
protected WebElement getVisibleDialogBox() { List<WebElement> dialogs = driver.findElements(By.className("ui-dialog")); WebElement goodDialog = null;/*from w w w . j a v a 2 s. c o m*/ SeleniumWaiter.waitForDialogBoxAppears(driver); for (WebElement dialog : dialogs) { if (dialog.getAttribute("aria-hidden").equals("false")) goodDialog = dialog; } return goodDialog; }
From source file:com.mroza.seleniumTests.ProgramDirectoryViewTests.ProgramDirectoryViewPage.java
License:Open Source License
public void setSearchValue(String expectedSearchedSymbol) { WebElement searchBoxInput = driver.findElement(By.className("ui-outputpanel")); searchBoxInput.findElement(By.tagName("input")).sendKeys(expectedSearchedSymbol); SeleniumWaiter.waitForJQueryAndPrimeFaces(driver); }
From source file:com.mroza.seleniumTests.ProgramDirectoryViewTests.ProgramDirectoryViewPage.java
License:Open Source License
public void setLetterFilterValue(String buttonValue) { WebElement buttonsArea = driver.findElement(By.className("ui-selectonebutton")); List<WebElement> letterButtons = buttonsArea.findElements(By.className("ui-button")); for (WebElement letterButton : letterButtons) { String buttonTextValue = letterButton.findElement(By.className("ui-button-text")).getText(); if (buttonTextValue.equals(buttonValue)) { letterButton.click();// ww w. ja va 2 s .c o m break; } } SeleniumWaiter.waitForJQueryAndPrimeFaces(driver); }
From source file:com.mx.santander.lh.obpyme.WebElement.ElementPageMarketingSantander.java
public List<WebElement> ListaURLBusqueda(WebDriver driver) { List<WebElement> listaURL = driver.findElements(By.className("r")); return listaURL; }
From source file:com.mycompany.fullslidertest.FullsliderTest.java
public void editText() { createPresentation("Edit Text"); waitForAction();//from w w w . j ava 2 s . com WebElement textElement = driver.findElement(By.xpath("//div[@id='workspace']/div[2]/div/section/div[1]")); WebElement text = driver.findElement(By.xpath("//div[@id='workspace']/div[2]/div/section/div[1]/div/font")); actions.doubleClick(textElement).build().perform(); actions.doubleClick(text).build().perform(); waitForAction(); driver.findElement(By.className("etch-bold")).click(); driver.findElement(By.xpath("//div[@id='etch-font-family']/a")).click(); driver.findElement(By.xpath("//div[@id='etch-font-family']/ul/li/a[6]")).click(); driver.findElement(By.id("workspace")).click(); waitForAction(); driver.quit(); }
From source file:com.mycompany.myselion.sample.selion.AppiumIOSDemoTest.java
License:Apache License
/** * This test demonstrates how to use SeLion for running tests against a Native IOS app using appium. * <ul>//from w w w .j a v a2 s . c o m * <li> * An appium instance/server should be locally installed and running and point SeLion to this server using any of the following options. * <ol> * <li>Through the JVM arguments -DSELION_SELENIUM_HOST and -DSELION_SELENIUM_PORT </li> (or) * <li>Through suite file <parameter name="seleniumhost" value=""/> and <parameter name="seleniumport" value=""/></li> * </ol></li> * For setting up Appium iOS refer http://appium.io/slate/en/master/?ruby#system-setup-(ios) * </li> * <li> * The app InternationalMountains.app to be tested should be placed in the * Current Working directory(src/test/resources).</li> * </ul> */ @MobileTest(appPath = "src/test/resources/apps/InternationalMountains.app", device = "iphone:8.1", deviceType = "iPhone Simulator") @Test public void testWithNativeApp() throws InterruptedException { //Log a screenshot to the report and label it "My Screenshot 1" SeLionReporter.log("My Screenshot 1", true); //To gain access to the IOSRemoteWebDriver, we use the thread safe helper method Grid.driver() which provides //an instance of IOSRemoteWebDriver for the current Test method. List<WebElement> cells = Grid.driver().findElements(By.className("UIATableCell")); assertEquals(9, cells.size()); // get the 1st mountain WebElement first = cells.get(0); first.click(); Thread.sleep(10 * 1000); //Log a screenshot to the report and label it "My Screenshot 2" SeLionReporter.log("My Screenshot 2", true); // access the content By selector = By.xpath("//UIAStaticText[contains(@name,'climbed')]"); WebElement text = Grid.driver().findElement(selector); Reporter.log(text.getAttribute("name"), true); }
From source file:com.mycompany.myselion.sample.selion.AppiumSauceCloudTest.java
License:Apache License
/** * This test demonstrates how to use SeLion for running tests against a Native IOS app in sauce cloud. * InternationalMountains.app.zip must be uploaded to sauce temporary storage before running this test case. */// ww w .j a v a 2 s. com @Test @MobileTest(appPath = "sauce-storage:InternationalMountains.app.zip", device = "iphone:8.1", deviceType = "iPhone Simulator", additionalCapabilities = { "appiumVersion:1.4.13" }) public void testWithNativeIOSApp() throws InterruptedException { SeLionReporter.log("My Screenshot 1", true); List<WebElement> cells = Grid.driver().findElements(By.className("UIATableCell")); assertEquals(9, cells.size()); // get the 1st mountain WebElement first = cells.get(0); first.click(); Thread.sleep(10 * 1000); SeLionReporter.log("My Screenshot 2", true); }
From source file:com.mycompany.myselion.sample.selion.IOSNativeAppDemoTest.java
License:Apache License
/** * This test demonstrates how to use SeLion for running tests against a Native IOS app using appium. * This test case needs an local IOS simulator spawned. *//*from w w w. j a v a 2s .c o m*/ @MobileTest(appName = "InternationalMountains") @Test public void testMethod() throws InterruptedException { //Log a screenshot to the report and label it "My Screenshot 1" SeLionReporter.log("My Screenshot 1", true); //To gain access to the IOSRemoteWebDriver, we use the thread safe helper method Grid.driver() //which provides an instance of IOSRemoteWebDriver for the current Test method. List<WebElement> cells = Grid.driver().findElements(By.className("UIATableCell")); assertEquals(9, cells.size()); // get the 1st mountain WebElement first = cells.get(0); first.click(); Thread.sleep(10 * 1000); //Log a screenshot to the report and label it "My Screenshot 2" SeLionReporter.log("My Screenshot 2", true); // access the content By selector = By.xpath("//UIAStaticText[contains(@name,'climbed')]"); WebElement text = Grid.driver().findElement(selector); Reporter.log(text.getAttribute("name"), true); }
From source file:com.mycompany.webcrawler.GmailAutomation.java
public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); DesiredCapabilities dcaps = new DesiredCapabilities(); dcaps.setCapability("takeScreenshot", true); //WebDriver driver = new PhantomJSDriver(dcaps); //Comment for PhantomJS ChromeDriver driver = new ChromeDriver(); //Comment for PhantomJS //driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); driver.get(//from w ww .ja v a 2 s . c om "https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&osid=1&service=mail&ss=1<mpl=default&rm=false#identifier"); try { Thread.sleep(2000); driver.findElement(By.id("Email")).sendKeys("Your gmail goes here"); Thread.sleep(2000); driver.findElement(By.id("next")).click(); Thread.sleep(2000); driver.findElement(By.id("Passwd")).sendKeys("Your password goes here"); Thread.sleep(2000); driver.findElement(By.id("signIn")).click(); Thread.sleep(2000); driver.findElement(By.xpath("//div[@class='T-I J-J5-Ji T-I-KE L3']")).click(); Thread.sleep(2000); driver.findElement(By.className("vO")).sendKeys("Who you want to send the email to"); Thread.sleep(2000); driver.findElement(By.className("aoT")).sendKeys("The subject"); Thread.sleep(2000); driver.switchTo().activeElement().sendKeys(Keys.TAB); driver.switchTo().activeElement().sendKeys("The body"); //Comment for PhantomJS //driver.findElement(By.xpath("//div[@class='Am Al editable LW-avf']")).sendKeys("Test Email"); Thread.sleep(2000); File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(file, new File("screenshot.jpg")); Thread.sleep(2000); driver.findElement(By.xpath("//div[@class='T-I J-J5-Ji aoO T-I-atl L3']")).click(); //Comment for PhantomJS //Thread.sleep(2000); //driver.get("https://mail.google.com/mail/u/0/#sent"); } catch (IOException | InterruptedException | WebDriverException e) { System.out.println(e.getMessage()); } }