List of usage examples for org.openqa.selenium WebDriver getTitle
String getTitle();
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.PageNavigation.PageNavigation3.java
License:Apache License
public void processDriver(WebDriver driver) { try {//from w w w . j a va2 s . com System.out.println("Page title is: " + driver.getTitle()); String url = driver.getCurrentUrl(); WebDriverWait wait = new WebDriverWait(driver, 5); By targetBy = By.id(""); By targetPath = By.id(""); if (url.contains("armslist")) { targetBy = By.id("termsagreement"); targetPath = By.xpath("//button[span='I Agree']"); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(targetBy)); element = element.findElement(targetPath); element.click(); } else if (url.contains("tennesseegunexchange")) { System.out.println("url contains msgun!!!!!"); targetBy = By.id("cw_enter_link"); WebElement ele = driver.findElement(targetBy); Actions action = new Actions(driver); action.moveToElement(ele).build().perform(); ele.click(); } } catch (Exception e) { System.out.println(e.toString()); } //System.out.println("=====DEBUG: click success!"); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.PageNavigation.PageNavigationUK1.java
License:Apache License
public void processDriverForArguntrader(final WebDriver driver) { if (driver.getTitle().toLowerCase().contains("login")) { WebElement username = driver.findElement(By.id("username")); WebElement password = driver.findElement(By.id("password")); username.sendKeys("shoot.dexter"); password.sendKeys("Curious@1234"); driver.findElement(By.className("button1")).click(); (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); }//from w w w . j ava2s .com return d.getCurrentUrl().toLowerCase().contains(driver.getCurrentUrl().toLowerCase()); } }); } }
From source file:io.github.bonigarcia.wdm.test.PerformanceRemoteTest.java
License:Apache License
private void singleTestExcution(WebDriver driver, int index) { driver.get("https://en.wikipedia.org/wiki/Main_Page"); String title = driver.getTitle(); assertTrue(title.equals("Wikipedia, the free encyclopedia")); SessionId sessionId = ((RemoteWebDriver) driver).getSessionId(); System.out.println(index + " -- " + sessionId + " -- " + title); }
From source file:io.github.bonigarcia.wdm.test.StabilityTest.java
License:Apache License
@Test public void test() throws InterruptedException { CountDownLatch latch = new CountDownLatch(NUM_THREADS); ExecutorService executorService = newFixedThreadPool(NUM_THREADS); for (int i = 0; i < NUM_THREADS; i++) { executorService.submit(() -> { try { WebDriverManager.chromedriver().setup(); ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); WebDriver driver = new ChromeDriver(options); driver.get("https://bonigarcia.github.io/selenium-jupiter/"); String title = driver.getTitle(); System.out.println(title); driver.quit();/*from ww w. j a v a 2s . com*/ } finally { latch.countDown(); } }); } latch.await(); executorService.shutdown(); }
From source file:io.selendroid.client.waiter.WaitingConditions.java
License:Apache License
public static Callable<String> pageTitleToBe(final WebDriver driver, final String expectedTitle) { return new Callable<String>() { public String call() throws Exception { String title = driver.getTitle(); if (expectedTitle.equals(title)) { return title; }/* ww w . j a va 2 s . c o m*/ return null; } @Override public String toString() { return "title to be: " + expectedTitle; } }; }
From source file:io.wcm.qa.galenium.reporting.GaleniumReportUtil.java
License:Apache License
/** * Take screenshot of current browser window and add to reports. * @param result//from ww w .ja va 2 s . co m * @param driver to take screenshot from * @return log message including screenshot if everything was successful */ public static String takeScreenshot(ITestResult result, WebDriver driver) { String destScreenshotFilePath = null; String filenameOnly = null; if (driver instanceof TakesScreenshot) { filenameOnly = System.currentTimeMillis() + "_" + result.getName() + ".png"; File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); try { File destFile = new File(PATH_SCREENSHOTS_ROOT, filenameOnly); FileUtils.copyFile(screenshotFile, destFile); destScreenshotFilePath = PATH_SCREENSHOTS_RELATIVE_ROOT + File.separator + filenameOnly; String screenCapture = getExtentTest().addScreenCapture(destScreenshotFilePath); getLogger().info(screenCapture); } catch (IOException ex) { log.error("Cannot copy screenshot.", ex); } } StringBuilder logMsg = new StringBuilder(); if (filenameOnly != null) { logMsg.append("Screenshot: ").append(PATH_SCREENSHOTS_ROOT).append(File.separator).append(filenameOnly) .append(System.lineSeparator()); if (destScreenshotFilePath != null) { String url = driver.getCurrentUrl(); String title = driver.getTitle(); Reporter.log("<a href=\"" + url + "\"><img src=\"" + destScreenshotFilePath + "\" alt=\"" + title + "\"/></a>", true); } } return logMsg.toString(); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Title_Do_It_Yourself(WebDriver driver) { String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "eCommerce Website Designer | Development"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Title_Work_With_A_Team(WebDriver driver) { String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "Magento Website Development | eCommerce Web Design | IWD Agency"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Button_SEETHEIRPROJECT_Work_With_A_Team(WebDriver driver) { driver.findElement(By.cssSelector("a[href*='/marucci-sporting-goods']")).click(); String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "Baton Rouge Louisiana Magento eCommerce Development by IWD"; assertEquals(expectedTitle, actualTitle); driver.navigate().back();/*from w ww .j a v a 2s. c o m*/ System.out.println("Title is correct"); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Title_Store_Optimization_Support(WebDriver driver) { String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "Magento Support & Help"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); }