List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:com.ibm.sbt.test.js.connections.profiles.rest.ReadProfilePhoto.java
License:Open Source License
@Test public void testNoError() { createContext();/*w ww .j a v a 2 s. c o m*/ addSnippetParam("sample.id1", TestEnvironment.getCurrentUserUuid()); ResultPage resultPage = launchSnippet("Social_Profiles_REST_Read_Profile_Photo", AuthType.NONE); WebElement contentEl = resultPage.getWebElement().findElement(By.id("content")); WebElement imgEl = contentEl.findElement(By.tagName("img")); assertNotNull("Unable to find image tag", imgEl); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickMenuIconTwiceShowsAndHidesMenu() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();/*from w w w . j av a 2s. c o m*/ WebElement menuList = driver.findElement(By.tagName("menu-list")); assertTrue("After clicking the menu icon, the menu list is visible", menuList.isDisplayed()); // Click the menu icon again, the menu list should go away menuIconImg.click(); assertFalse("Clicking on the menu icon again closes the menu list", menuList.isDisplayed()); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Ignore @Test//from w ww .j a v a 2 s. c om public void clickMenuIconThenAwayFromMenuIconHidesMenuList() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); // Clicking away from the menu icon should also close the menu menuIconImg.click(); WebElement menuList = driver.findElement(By.tagName("menu-list")); assertTrue("After clicking the menu icon, the menu list is visible", menuList.isDisplayed()); Actions action = new Actions(driver); action.moveToElement(driver.findElement(By.tagName("body")), 0, 0); action.click().build().perform(); assertFalse("After clicking outside the menu icon, the menu list is gone", menuList.isDisplayed()); }
From source file:com.ibm.watson.app.qaclassifier.selenium.WelcomePageIT.java
License:Open Source License
@Test public void pageLoadsSuccessfully() throws Exception { assertEquals("The page title should be correct on load.", "Showcase App for NL Classifier", driver.getTitle());//from www . j a v a 2 s . co m assertTrue("The welcome screen is visible", driver.findElement(By.tagName("welcome")).isDisplayed()); }
From source file:com.isocket.gui.advertisers.PropertyProfilePage.java
License:Apache License
public CampaignPage createCampaignForLocation(String name, Campaign campaign) { boolean isFound = false; for (ExtendedWebElement location : locationRows) { if (location.getText().contains(name)) { click("addCampaignButton", location.getElement().findElement(By.tagName("button"))); isFound = true;//from w w w .j a va 2 s . co m } } Assert.assertTrue(isFound, String.format("Location '%s' not found", name)); click(newCampaignButton); populateCampaign(campaign); click(createCampaignButton); return new CampaignPage(driver); }
From source file:com.jaeksoft.searchlib.crawler.web.browser.BrowserDriver.java
License:Open Source License
final public String getJavascriptBody() { try {//from www. j a v a 2s.c o m return driver.findElement(By.tagName("body")).getText(); } catch (NoSuchElementException e) { return null; } }
From source file:com.jaeksoft.searchlib.crawler.web.spider.ClickCapture.java
License:Open Source License
private boolean locateElement(BrowserDriver<?> browserDriver, WebElement webElement) throws SearchLibException, IOException { By by = By.cssSelector("a"); List<WebElement> aElements = webElement == null ? browserDriver.locateBy(by) : webElement.findElements(by); if (locateAimgClickCapture(aElements)) return true; by = By.cssSelector("embed"); List<WebElement> embedElements = webElement == null ? browserDriver.locateBy(by) : webElement.findElements(by); if (locateEmbedClickCapture(embedElements)) return true; by = By.cssSelector("object > object"); List<WebElement> objectElements = webElement == null ? browserDriver.locateBy(by) : webElement.findElements(by); if (locateEmbedClickCapture(objectElements)) return true; by = By.tagName("iframe"); List<WebElement> iFrameElements = webElement == null ? browserDriver.locateBy(by) : webElement.findElements(by); if (locateIFrame(browserDriver, iFrameElements)) return true; return false; }
From source file:com.jaeksoft.searchlib.crawler.web.spider.HtmlArchiver.java
License:Open Source License
final public void archive(BrowserDriver<?> browserDriver, Set<String> xPathDisableScriptSet) throws IOException, ParserConfigurationException, SAXException, IllegalStateException, SearchLibException, URISyntaxException, XPatherException { String pageSource = browserDriver.getSourceCode(); HtmlCleanerParser htmlCleanerParser = new HtmlCleanerParser(); htmlCleanerParser.init(pageSource);// www .j av a2s . c o m // Find iframe Set<WebElement> iframeWebElementSet = new HashSet<WebElement>(); browserDriver.locateBy(By.tagName("iframe"), iframeWebElementSet, true); Map<TagNode, WebElement> iframeNodeMap = null; if (iframeWebElementSet != null && iframeWebElementSet.size() > 0) { iframeNodeMap = new HashMap<TagNode, WebElement>(); Set<TagNode> tagNodeSet = new HashSet<TagNode>(); for (WebElement webElement : iframeWebElementSet) { String xPath = browserDriver.getXPath(webElement, true); if (xPath == null) continue; if (htmlCleanerParser.xpath(xPath, tagNodeSet) == 0) { Logging.warn("DisableScript not found using XPath: " + xPath); continue; } for (TagNode tagNode : tagNodeSet) iframeNodeMap.put(tagNode, webElement); tagNodeSet.clear(); } } // Find node that need to be disabled Set<TagNode> disableScriptNodeSet = null; if (xPathDisableScriptSet != null && xPathDisableScriptSet.size() > 0) { disableScriptNodeSet = new HashSet<TagNode>(); for (String xPath : xPathDisableScriptSet) if (htmlCleanerParser.xpath(xPath, disableScriptNodeSet) == 0) Logging.warn("DisableScript not found using XPath: " + xPath); } recursiveArchive(htmlCleanerParser.getTagNode(), disableScriptNodeSet, iframeNodeMap); htmlCleanerParser.writeHtmlToFile(indexFile); String charset = htmlCleanerParser.findCharset(); if (charset == null) FileUtils.write(sourceFile, pageSource); else FileUtils.write(sourceFile, pageSource, charset); }
From source file:com.java.AppTestType_18_11_2015.java
public void BIDONOWNLOT(WebDriver driver, String fieldText, String value) { try {// ww w .j a v a2s . c o m driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); AMPLOGIN(driver, value); driver.findElement(By.linkText("Lots")).click(); Thread.sleep(4000); new Select(driver.findElement(By.xpath("//select[@name='venueID']"))) .selectByVisibleText("EquipmentOne"); new Select(driver.findElement(By.xpath("//select[@name='offerSrhListingStatus']"))) .selectByVisibleText("Approved"); driver.findElement(By.xpath("//input[@name='find_button']")).click(); driver.findElement(By.xpath("//*[@id='renderView']/table[2]/tbody/tr[1]/td[2]/table/tbody/tr[1]/td/a")) .click(); String EQID = driver .findElement(By.xpath("//td[@class='listdatabold' and text()='Lot Number:']/../td[4]")) .getText(); System.out.println("EQID is: " + EQID); driver.findElement(By.xpath("//td[@class='listdatabold' and text()='Seller:']/../td[2]/a")).click(); Thread.sleep(5000); String SellerMailID = driver.findElement(By.id("id_frm_Email_Address")).getAttribute("value"); System.out.println("SellerMailID is: " + SellerMailID); AMPLOGOUT(driver); driver.get(fieldText); WebDriverWait wait = new WebDriverWait(driver, 30); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(SellerMailID); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); Thread.sleep(4000); driver.findElement(By.id("search")).sendKeys(EQID); driver.findElement(By.xpath("//*[@id='main_search']/button")).click(); Thread.sleep(4000); //driver.findElement(By.xpath("(//*[@name='makeoffer'])[2]")).click(); driver.findElement(By.xpath("(//*[@name='makeoffer'])[2]")).sendKeys("99999999999"); driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//input[@class='form-control jsOfferInput e1ConfirmInput'])[2]")) .sendKeys("99999999999"); driver.findElement(By.xpath("(//input[@class='btn btn-primary jsConfirmOffer'])[2]")).click(); Thread.sleep(4000); if (driver.findElement(By.tagName("html")).getText() .contains("You are attempting to place a bid on a lot you own, this is not allowed.")) resultDetails.setFlag(true); } catch (Exception e2) { e2.printStackTrace(); resultDetails.setErrorMessage("something went wrong"); resultDetails.setFlag(false); } }
From source file:com.java.cukes.CheckoutSteps.java
License:Apache License
@Then("^I should see products$") public void I_should_see_products() throws Throwable { new WebDriverWait(driver, 120).until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("h1"), "SEARCH RESULTS FOR 'SAMSUNG'")); // assertEquals(driver.findElement(By.cssSelector("h1")).getText(), "SEARCH RESULTS FOR 'SAMSUNG'"); }