List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:com.bc.opec.webtests.TestUserInfo.java
License:Open Source License
@Test public void testThatUserInfoBalloonIsShown() throws Exception { WebElement webElement = driver.findElement(By.xpath("//*/div[@aria-describedby='user-info-balloon']")); assertNotNull(webElement);/*from ww w . ja v a 2s .c o m*/ if (webElement.getAttribute("aria-describedby").equals("user-info-balloon")) { assertEquals("none", webElement.getCssValue("display").toLowerCase()); final WebElement element = driver.findElement(By.id("userInfoToggleBtn")); Actions actions = new Actions(driver); actions.moveToElement(element).click().perform(); assertEquals("block", webElement.getCssValue("display").toLowerCase()); } }
From source file:com.bc.opec.webtests.WebTestBase.java
License:Open Source License
public void closePopups() { Assert.assertTrue(driver.getTitle().startsWith("OPEC")); for (WebElement e : driver.findElements(By.tagName("Button"))) { if (e.getAttribute("title").equals("Close")) { e.click();//w w w. ja va 2 s .c om break; } } for (WebElement e : driver.findElements(By.tagName("Button"))) { if (e.getText().equals("No")) { e.click(); break; } } driver.findElement( By.xpath("//*/div[@aria-describedby='gisportal-layerSelection']/div/div/button[@title='close']")) .click(); }
From source file:com.capgemini.scripts.Circuit.java
public void contacts() { try {//from ww w. j a v a2 s.c om // Thread.sleep(2000); BasicOperation.click("Tab_Contacts", webDriver); String data = DataMap.get("Module"); int skip = 0; if (data.equalsIgnoreCase("update")) { List<String> availableContacts = new ArrayList<>(); BasicOperation.waitFor(2000); for (int k = 0; k < 5; k++) { try { String value = webDriver .findElement(By.xpath( ".//*[@id='circuitSearchForm:contactNameTable:" + k + ":j_idt677']/label")) .getText(); availableContacts.add(value); } catch (Exception e) { } } if (availableContacts.contains(DataMap.get("Contact_Name"))) { skip = 1; } System.out.println(availableContacts); } if (skip == 0) { BasicOperation.click("Button_GetExistingContact", webDriver); BasicOperation.fill("Textbox_CompanyName", "Contact_Name", webDriver); BasicOperation.click("Button_Search_Contact", webDriver); BasicOperation.waitFor(5000); BasicOperation.click(".//table[@id='contactSearchResultsForm:dtTable']/tbody/tr/td[1]/span/a", webDriver); BasicOperation.waitFor(5000); for (int i = 7; i < 9; i++) { BasicOperation.waitFor(1500); BasicOperation.selectById( ".//*[@id='circuitSearchForm:contactAssgTable:" + i + ":contactNameList']", 1, webDriver); BasicOperation.waitFor(1500); BasicOperation.selectById(".//*[@id='circuitSearchForm:contactAssgTable:" + i + ":infoType']", 1, webDriver); } } // BasicOperation.takeScreenShot(); // LoadDriver.Wait(5000); BasicOperation.waitFor(1500); BasicOperation.click("Button_Save", webDriver); BasicOperation.waitFor(7000); BasicOperation.checkForException(webDriver); System.out.println("inside contacts"); BasicOperation.waitFor(15000); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:com.ceiwc.compugain.setup.TestBase.java
/** * // w w w . j a v a 2 s. c o m * @return : The language present in the HTML. */ public String getLanguagevalue(WebDriver driver) { String sflag = ""; logger.info("message" + driver.findElement(By.xpath("//html[@class='ng-scope']")).getAttribute("lang")); if (driver.findElement(By.xpath("//html[@class='ng-scope']")).getAttribute("lang") != null) { sflag = driver.findElement(By.xpath("//html[@class='ng-scope']")).getAttribute("lang"); } else { sflag = "en"; } return sflag; }
From source file:com.ceiwc.compugain.setup.TestBase.java
public void logout(WebDriver driver) { try {//from w w w .ja va 2s .c o m if (driver.findElement(By.xpath("//div[@id='account']/a/span")).isDisplayed()) { WebDriverWait driverwait = new WebDriverWait(driver, 60); driver.findElement(By.xpath("//div[@id='account']/a/span")).click(); driverwait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@class='glyphicons power']"))); driver.findElement(By.xpath("//*[@class='glyphicons power']")).click(); driverwait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='password']/input"))); } } catch (Exception e) { logger.info("Logout button is not found!!!!!"); } }
From source file:com.cengage.mindtap.keywords.BasePageActions.java
protected void waitForSpinnerToDisappear() { int i = 0;/*from www. ja v a 2s . c o m*/ wait.resetImplicitTimeout(5); try { List<WebElement> spinnerGifs = driver .findElements(By.xpath("//img[contains(@src, '/nb/ui/images/savingAnimation_')]")); if (spinnerGifs.size() > 0) { for (WebElement spinnerGif : spinnerGifs) { while (spinnerGif.isDisplayed() && i <= AJAX_WAIT) { wait.hardWait(5); i++; } } } } catch (Exception e) { } wait.resetImplicitTimeout(AJAX_WAIT); }
From source file:com.cengage.mindtap.keywords.BasePageActions.java
void switchToPrintPreviewIFrame() { driver.switchTo().frame(driver.findElement( By.xpath("//iframe[contains(@id, '_NB_Dock_IFrame') and contains(@src,'print_preview')]"))); }
From source file:com.cengage.mindtap.keywords.BasePageActions.java
void switchToToActivityIFrame() { driver.switchTo().frame(driver.findElement(By.xpath( "//iframe[contains(@id, 'distinct_activity_create_frame') and not(contains(@style,'none'))]"))); }
From source file:com.cengage.mindtap.keywords.BasePageActions.java
/** * Switch to activity i frame./*from w ww . ja v a 2 s .c om*/ */ void switchToMainIFrame() { switchToFrame(driver.findElement(By.xpath( "//iframe[contains(@id, '_NB_Main_IFrame') and not(contains(@style,'none')) and contains(@src,'nbreader')]"))); //driver.switchTo().frame(MainIFrame); }
From source file:com.cengage.mindtap.keywords.BasePageActions.java
public void waitForDomToLoad() { WebDriverWait wait = new WebDriverWait(driver, 80); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*"))); }