List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:ch.vorburger.vaadin.designer.tests.web.DesignerWebDriverTest.java
License:Apache License
@BeforeClass public static void setUpClass() throws Exception { // This is needed (only) for stand-alone EMF initialization SamplescreenPackage.eINSTANCE.eClass(); final String path = "/ch/vorburger/vaadin/designer/samplescreen/screen1.xmi"; URL url = DesignerWebDriverTest.class.getResource(path); if (url == null) throw new IOException("Could not getResource() for " + path); screen = new EIO().load(URI.createURI(url.toString()), Screen.class); driver = newWebDriver();//from w w w. j a v a 2s. c o m wait = new WebDriverWait(driver, 10); action = new Actions(driver); server = new DesignerServer(); server.start(); root = new SampleFixedScreenComponent(); new SampleFixedScreenBinding().bind(root, screen); server.getDesignerApplication().setRootContent(root); driver.get(server.getURL()); wait.until(ExpectedConditions.elementToBeClickable(By.id("name"))); }
From source file:ch.vorburger.vaadin.designer.tests.web.VaadinServerTest.java
License:Apache License
@Test @Ignore // TODO reactivate when http://dev.vaadin.com/ticket/9386 is fixed? public void testStartVaadinServer() throws Exception { VaadinServer server = new VaadinServer() { @Override//from w w w . j a v a 2 s. co m protected Class<? extends Application> getVaadinApplicationClass() { return VaadinTestApplication.class; } }; try { server.start(); // Check if "Saluton!" button shows up: WebDriver driver = new InternetExplorerDriver(); driver.get(server.getURL()); WebElement button = driver.findElement(By.id(HTML_ID)); String text = button.getText(); Assert.assertEquals("Saluton!", text); driver.quit(); } finally { server.stop(); } }
From source file:ch.vorburger.webdriver.reporting.tests.SampleGoogleSearchReportTest.java
License:Apache License
@Test public void testGoogleSearch() { EventFiringWebDriver driverWithReporting; {/*from ww w.ja va 2s .c o m*/ // System.setProperty("webdriver.chrome.driver", "/opt/google/chrome/chrome"); // WebDriver driver = new ChromeDriver(); WebDriver driver = new FirefoxDriver(); WebDriverEventListener loggingListener = new LoggingWebDriverEventListener(LOG_FILE_WRITER); ; driverWithReporting = new EventFiringWebDriver(driver); driverWithReporting.register(loggingListener); } driverWithReporting.get("http://www.google.com"); WebElement element = driverWithReporting.findElement(By.name("q")); element.sendKeys("Mifos"); element.submit(); (new WebDriverWait(driverWithReporting, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("bfoot"))); driverWithReporting.quit(); }
From source file:chromedriveryahoologin.ChromeDriverDeleteTrashEmails.java
public static void main(String[] args) { try {//from w w w . j a v a2s . com Integer pozSpam = 0; Integer pozTrash = 0; Integer pozHelp = 0; Integer pozCompose = 0; Integer pozNewFolder = 0; System.setProperty("webdriver.chrome.driver", "D:\\Proiecte\\selenium-java-2.47.1\\selenium-2.47.1\\chromedriver_win32\\chromedriver.exe"); System.setProperty("webdriver.chrome.logfile", "D:\\prjAutJava\\YahooLogin\\ChromeDriverDeleteSpam.log"); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); options.addArguments("--start-maximized"); options.addArguments("--disable-web-security"); options.addArguments("--no-proxy-server"); options.addArguments("--disable-extensions"); options.addArguments("--disable-notifications"); options.addArguments("--disable-popup-blocking"); options.addArguments("--disable-plug-in"); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); options.setExperimentalOption("prefs", prefs); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true); capabilities.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true); capabilities.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT, true); capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true); capabilities.setCapability(CapabilityType.PLATFORM, "WIN10"); driver = new ChromeDriver(capabilities); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get("https://mail.yahoo.com"); driver.manage().window().maximize(); WebElement usernameElem = driver.findElement(By.id("login-username")); usernameElem.sendKeys("andadeacu@yahoo.com"); WebElement Next = driver.findElement(By.name("signin")); Next.click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); WebElement passwordElem = driver.findElement(By.xpath("//input[@id='login-passwd']")); boolean selected = passwordElem.isSelected(); CharSequence password = ""; passwordElem.sendKeys(password); WebElement login = driver.findElement(By.id("login-signin")); login.click(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.switchTo().activeElement(); WebElement tooltipElem = driver.findElement(By.xpath("//div[@class='Pos(r) M(0) TooltipContent']")); List<WebElement> childs = tooltipElem.findElements(By.xpath("//ul/li")); for (int j = 0; j < childs.size(); j++) { WebElement spamElem = childs.get(j); /* * System.out.println("ancorele " + j + " " + " tag " + * childs.get(j).getTagName() + " " + childs.get(j).getText() + * " " + childs.get(j).getAttribute("innerHTML")); */ if (spamElem.getText().startsWith(("Spam"))) { pozSpam = j; } if (spamElem.getText().startsWith(("Help"))) { pozHelp = j; } if (spamElem.getText().startsWith(("Compose"))) { pozCompose = j; } if (spamElem.getText().startsWith(("New"))) { pozNewFolder = j; } if (spamElem.getText().startsWith(("Trash"))) { System.out.println(j + " Trash is " + spamElem.getTagName() + " " + spamElem.getText()); pozTrash = j; break; } } System.out.println(pozTrash); WebElement trashElem = childs.get(pozTrash); /* * System.out.println("trashElem " + trashElem.getTagName() + * " text " + trashElem.getText() + " class_atribute " + * trashElem.getAttribute("class") + " data_action " + * trashElem.getAttribute("data_action")); */ WebElement trashFolderEmpty = trashElem.findElement( By.xpath("//a[@class='x-gap btn btn-trash']/span/span[@class='btn icon icon-delete']")); /* * System.out.println("spamEmptyFolder " + * spamFolderEmpty.getTagName() + " text " + * spamFolderEmpty.getText() + " location " + * spamFolderEmpty.isEnabled()); */ trashFolderEmpty.click(); int timeOut = 5; WebDriverWait wait = new WebDriverWait(driver, timeOut); driver.switchTo().alert(); /* for Chrome is not working WebElement modalPopUp = driver.findElement(By .className("modal-hd yui3-widget-hd")); */ WebElement btnDeleteSpamEmails = driver.findElement(By.className("btn left right default")); /* * <button id="okayModalOverlay" class="btn left right default" * title="OK" role="button" data-action="ok">OK</button> */ btnDeleteSpamEmails.click(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.switchTo().activeElement(); // verify msg after you delete spam emails System.out.println(driver.getCurrentUrl()); driver.quit(); } catch (Exception ex) { ex.printStackTrace(); driver.quit(); } }
From source file:cls.ui.model.selenium.carDealerManage.BasicInfoPage.java
public Boolean isLoadSuccess() { driver.switchTo().defaultContent();// www . j a v a 2 s . c o m driver.switchTo().frame("iframe_undefined"); new WebDriverWait(driver, 5).until(ExpectedConditions.presenceOfElementLocated(By.id("dealerName"))); Boolean flag = false; WebElement dealerName = driver.findElement(By.id("dealerName")); if (dealerName != null) { flag = true; } return flag; }
From source file:cls.ui.model.selenium.carDealerManage.BasicInfoPage.java
public void selectRecommendName(String recommendName) throws Throwable { WebElement recommendNameSelect = driver.findElement(By.id("employDealerId")); Select mySelect = new Select(recommendNameSelect); mySelect.selectByVisibleText(recommendName); }
From source file:cls.ui.model.selenium.secondhandcarmanagement.StartAssessmentPage.java
public void selectBrand(String letter, String brand) throws Throwable { WebElement brandInput = driver.findElement(By.id("getBrand")); brandInput.click();//w w w . j a va 2 s . c o m List<WebElement> letterLst = driver.findElements(By.xpath( "/html/body/div/div/div/div/div/div[2]/div[1]/div/div[1]/div/div/form/div[2]/div[2]/div[2]/div[1]/div/ul/div[2]/a")); for (int i = 0; i < letterLst.size(); i++) { WebElement letterBtn = letterLst.get(i); if (letterBtn.getText().equals(letter)) { letterBtn.click(); break; } } List<WebElement> brandLst = driver.findElements(By.xpath( "/html/body/div[1]/div/div/div/div/div[2]/div[1]/div/div[1]/div/div/form/div[2]/div[2]/div[2]/div[1]/div/ul/div[1]/li")); for (int i = 0; i < brandLst.size(); i++) { WebElement brandBtn = brandLst.get(i); if (brandBtn.getText().equals(brand)) { brandBtn.click(); break; } } Thread.sleep(1000); }
From source file:cls.ui.model.selenium.secondhandcarmanagement.StartAssessmentPage.java
public void selectCarSeries(String carSeries) throws Throwable { WebElement carSeriesSelect = driver.findElement(By.id("getCarList")); Select mySelect = new Select(carSeriesSelect); mySelect.selectByVisibleText(carSeries); Thread.sleep(1000);/* w w w . j a v a 2s . c o m*/ }
From source file:cls.ui.model.selenium.secondhandcarmanagement.StartAssessmentPage.java
public void selectCarModel(String carModel) { WebElement carModelSelect = driver.findElement(By.id("getCarModel")); Select mySelect = new Select(carModelSelect); mySelect.selectByVisibleText(carModel); }
From source file:cls.ui.model.selenium.secondhandcarmanagement.StartAssessmentPage.java
public void clickConfirmButtom() throws Throwable { WebElement confrimBtn = driver.findElement(By.id("sureOption")); confrimBtn.click();//www . j ava 2s.c o m Thread.sleep(2000); }