List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:at.ac.tuwien.big.testsuite.impl.selenium.BaseSeleniumTest.java
License:Apache License
protected final WebDriver createDriver() throws Exception { Exception exception = null;/* ww w. j a v a 2 s. com*/ WebDriver webDriver = null; int tries = 0; while (tries < MAX_DRIVER_GET_RETRY) { try { if (chromeService != null) { webDriver = new RemoteWebDriver(chromeService.getUrl(), DesiredCapabilities.chrome()); } else { webDriver = new ChromeDriver(); } } catch (Exception ex) { exception = ex; try { webDriver = new FirefoxDriver(); } catch (Exception ex1) { exception.addSuppressed(ex1); try { webDriver = new SafariDriver(); } catch (Exception ex2) { exception.addSuppressed(ex2); try { if (ieService != null) { webDriver = new RemoteWebDriver(ieService.getUrl(), DesiredCapabilities.internetExplorer()); } else { webDriver = new InternetExplorerDriver(); } } catch (Exception ex3) { exception.addSuppressed(ex3); } } } } if (webDriver != null) { break; } } if (webDriver == null) { throw new RuntimeException("Could not find a browser for testing", exception); } webDrivers.add(webDriver); webDriver.get(webappUrl); if (login != null) { user = login.doLogin(webDriver); if (user == null) { user = ""; errorCollector.checkThat("Could not login", true, is(false)); } } return webDriver; }
From source file:au.com.onegeek.lambda.BrowserFactoryTest.java
License:Apache License
@Test public void testBrowserFactory() throws Exception { String browser = "chrome"; String hostname = "http://ote.retail.melbourneit.com.au"; WebDriverBackedSeleniumProvider selenium = null; WebDriver driver = null; // System.setProperty("webdriver.chrome.driver", "/Users/mfellows/development/lambda/lambda-assembly/lib/chromedriver-macosx"); System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver"); // driver = new FirefoxDriver(); // driver = new ChromeDriver(); driver = BrowserFactory.getDriver(browser); driver.get(hostname); selenium = new WebDriverBackedSeleniumProvider(driver, hostname); // try { // logger.debug("Creating " + browser + " Driver."); // driver = BrowserFactory.getDriver(browser); // driver.get(hostname); // } catch (Exception e) { // e.printStackTrace(); // logger.debug("Could not create driver for browser '" + browser // + "' because of: " + e.getMessage() + "\n Exiting now..."); // System.exit(1); // }//from w w w. j a va 2 s.c om // // // Start the Selenium Server // try { // selenium = new WebDriverBackedSeleniumProvider(driver, hostname); // } catch (Exception e) { // e.printStackTrace(); // logger.debug("Could not start selenium or the server because: " // + e.getMessage()); // } //selenium.open("http://ote.retail.melbourneit.com.au"); //logger.info(selenium.getHtmlSource()); // WebElement nameid = driver.findElement(By.id("nameid")); // nameid.sendKeys("hello.com.au"); // nameid.submit(); selenium.open(hostname); selenium.type("nameid", "foobar"); // selenium.type("nameid", "foobar"); // selenium.assertTitle("Google2"); // Thread.sleep(10000); // selenium.stop(); driver.quit(); selenium = null; driver = null; }
From source file:authentication.AccountInfo.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed WebDriver driver = new ChromeDriver(); driver.get( "https://www.facebook.com/?stype=lo&jlou=Afeo3usnUHyB5AT4TqVF4PpoNba5Ld2sOALGhGMfhib8xyeI0FjYqdYf72ZtVncLyfHnYBBU6pY3XZ_l-D-KchQXCwLecdkAemJcXs_dIu-UmQ&smuh=16711&lh=Ac-txP8J-TK6lCJ5"); WebElement username = driver.findElement(By.id("email")); WebElement password = driver.findElement(By.id("pass")); username.sendKeys(b.getUserName());// ww w . j av a2s . co m password.sendKeys(b.getPassWord()); WebElement button = driver.findElement(By.id("loginbutton")); button.click(); }
From source file:authentication.TestingTable.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); WebDriver driver = new ChromeDriver(); driver.get( "https://www.facebook.com/?stype=lo&jlou=Afeo3usnUHyB5AT4TqVF4PpoNba5Ld2sOALGhGMfhib8xyeI0FjYqdYf72ZtVncLyfHnYBBU6pY3XZ_l-D-KchQXCwLecdkAemJcXs_dIu-UmQ&smuh=16711&lh=Ac-txP8J-TK6lCJ5"); WebElement username = driver.findElement(By.id("email")); WebElement password = driver.findElement(By.id("pass")); password.sendKeys(model.getValueAt(jTable1.getSelectedRow(), 0).toString()); username.sendKeys(model.getValueAt(jTable1.getSelectedRow(), 1).toString()); WebElement button = driver.findElement(By.id("loginbutton")); button.click();// w w w .j ava2s .com }
From source file:be.ugent.mmlab.webdriver.Demo.java
License:Apache License
public void demoTime() throws InterruptedException { // initialize web browser. WebDriver driver = new FirefoxDriver(); // go to the Belgian railways website driver.get("http://www.belgianrail.be"); // select "English" // HTML://from ww w . j a v a 2 s . co m // <a // id="ctl00_bodyPlaceholder_languagesList_ctl02_languageNameLink" // href="javascript:__doPostBack('ctl00$bodyPlaceholder$languagesList$ctl02$languageNameLink','')" // > English </a> WebElement english = driver .findElement(By.id("ctl00_bodyPlaceholder_languagesList_ctl02_languageNameLink")); english.click(); // fill out departure WebElement from = driver.findElement(By.id("departureStationInput")); from.sendKeys("Gent-Dampoort"); // pause for a second to make it not too fast Thread.sleep(1000); // click in the field to get the auto-completion away from.click(); // fill out arrival WebElement to = driver.findElement(By.id("arrivalStationInput")); to.sendKeys("Brussel-Noord"); Thread.sleep(1000); to.click(); // click timetable button WebElement timetableButton = driver.findElement(By.id( "ctl00_ctl00_bodyPlaceholder_bodyPlaceholder_mobilityTimeTableSearch_HomeTabTimeTable1_submitButton")); timetableButton.click(); // get departure info // HTML: // <td headers="hafasOVTimeOUTWARD" class="time"> // <div> // <div class="planed overviewDep"> // 10:00 dep <span class="bold prognosis">+12 min.</span> // </div> // <div class="planed"> // 11:20 arr <span class="bold green">+0 min.</span> // </div> // </div> // </td> List<WebElement> timeCells = driver.findElements(By.className("time")); for (WebElement timeCell : timeCells) { List<WebElement> times = timeCell.findElements(By.className("planed")); System.out.println("----------------------------------------------"); System.out.println("departure time: " + times.get(0).getText()); System.out.println("arrival time: " + times.get(1).getText()); } }
From source file:bi.com.seleniumgrid.PhantomJsTest.java
License:Apache License
@Test public void test() { final DesiredCapabilities capabilities = new DesiredCapabilities(); // Configure our WebDriver to support JavaScript and be able to find the PhantomJS binary capabilities.setJavascriptEnabled(true); capabilities.setCapability("takesScreenshot", false); capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, PHANTOMJS_BINARY); final WebDriver driver = new PhantomJSDriver(capabilities); // Your test code here. For example: WebDriverWait wait = new WebDriverWait(driver, 30); // 30 seconds of timeout driver.get("https://en.wikipedia.org/wiki/Main_Page"); // navigate to Wikipedia pageTitle = driver.getTitle().trim(); Assert.assertEquals(pageTitle, "GoalQuest"); System.out.println("Page title is: " + driver.getTitle()); By searchInput = By.id("searchInput"); // search for "Software" wait.until(ExpectedConditions.presenceOfElementLocated(searchInput)); driver.findElement(searchInput).sendKeys("Software"); By searchButton = By.id("searchButton"); wait.until(ExpectedConditions.elementToBeClickable(searchButton)); driver.findElement(searchButton).click(); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), "Computer software")); // assert that the resulting page contains a text }
From source file:br.com.esign.logistics.test.selenium.page.HomePage.java
License:Open Source License
public HomePage(WebDriver driver) { this.driver = driver; driver.get(PAGE_URL); PageFactory.initElements(driver, this); }
From source file:br.edu.ifpb.praticas.testSystem.TituloPaginaT.java
@Test public void testTitulo() throws Exception { WebDriver driver = new FirefoxDriver(); driver.get("http://localhost:8085/SisFilme/index.xhtml"); assertEquals("Avalie filmes", driver.getTitle()); (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { @Override/*from w ww .j a v a2 s.c o m*/ public Boolean apply(WebDriver d) { return d.getTitle().contains("Avalie filmes"); } }); //Close the browser driver.quit(); }
From source file:businesscomponents.ReportCompare1.java
public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub WebDriver driver = new FirefoxDriver(); driver.get("http://148.173.174.122:8900/acadmin/?serverURL=http://wpqwa551:8000"); driver.manage().window().maximize(); String strUserName = "kgoutham"; String strPassWord = "kgoutham"; driver.findElement(By.name("userID")).clear(); driver.findElement(By.name("userID")).sendKeys(strUserName); driver.findElement(By.name("Password")).clear(); driver.findElement(By.name("Password")).sendKeys(strPassWord); driver.findElement(By.name("loginBtn")).click(); Thread.sleep(1200);//from w w w. j a v a 2s . c o m System.out.println("Page title is: " + driver.getTitle()); if (driver.getTitle().contains("Files & Folders")) { driver.findElement(By.id("Jobs")).click(); Thread.sleep(2500); driver.switchTo().defaultContent(); WebElement frame = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(frame); Thread.sleep(1200); if (driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).isDisplayed()) { try { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]"))); } catch (Exception e) { driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).click(); } System.out.println("Clicking on Completed Tabs"); } else { System.out.println("Failed:Unable to Find the Completed Tab section"); } Thread.sleep(1200); WebElement frame1 = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(frame1); String strValue = "MRF412"; driver.findElement(By.id("FilterText")).clear(); driver.findElement(By.id("FilterText")).sendKeys(strValue); Thread.sleep(1200); driver.findElement(By.xpath("//input[@value='Apply']")).click(); Thread.sleep(3500); WebElement frame2 = driver.findElement(By.id("ifrListFrame")); driver.switchTo().frame(frame2); if (driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).isDisplayed()) { String oldTab = driver.getWindowHandle(); driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).click(); Thread.sleep(5000); ArrayList<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); // change focus to new tab driver.switchTo().window(newTab.get(0)); WebElement frame3 = driver.findElement(By.id("reportframe")); driver.switchTo().frame(frame3); String strPageSource = driver.getPageSource(); CommonData.strPageSource = strPageSource; String strPageTitle = driver.findElement(By.xpath("//div[contains(@id,'water')]")).getText(); CommonData.strPageTitle = strPageTitle; if (strPageTitle.contains("MultiUserTest License")) { System.out.println("Verifying the MultiUserTest License page is displayed"); List<WebElement> products = driver .findElements(By.xpath("//div[contains(@onmouseover,'Partner Name')]")); ArrayList<String> strPartnerName = CommonData.strPartnerName; ArrayList<String> strInvoiceNumber = CommonData.strInvoiceNumber; ArrayList<String> strTotalPayment = CommonData.strTotalPayment; ArrayList<String> strSENumber = CommonData.strSENumber; ArrayList<String> strPaymentMarket = CommonData.strPaymentMarket; ArrayList<String> strPaymentunit = CommonData.strPaymentunit; ArrayList<String> strLiabilityUnit = CommonData.strLiabilityUnit; ArrayList<String> strLiabilityCurrency = CommonData.strLiabilityCurrency; ArrayList<String> strMarketCurrency = CommonData.strMarketCurrency; ArrayList<String> strInvoiceReleaseDate = CommonData.strInvoiceReleaseDate; ArrayList<String> strUserId = CommonData.strUserId; for (int i = 1; i <= products.size(); i++) { System.out.println( "-----------------DISPLAYING LIST OF TABLE VALUES----------------------->: " + i); String strPartnerNameList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Partner Name')])[" + i + "]")) .getText(); strPartnerName.add(strPartnerNameList); System.out.println("Displaying the Partner Name list :" + strPartnerNameList); String strInvoiceNumberList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Invoice Number')])[" + i + "]")) .getText(); strInvoiceNumber.add(strInvoiceNumberList); System.out.println("Displaying the Invoice Number list :" + strInvoiceNumberList); String strTotalPaymentList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + j + "]")) .getText(); } else { strTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + i + "]")) .getText(); } strTotalPayment.add(strTotalPaymentList); System.out.println("Displaying the Total Payment list :" + strTotalPaymentList); String strSENumberList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'SE Number')])[" + i + "]")) .getText(); strSENumber.add(strSENumberList); System.out.println("Displaying the SE Number list :" + strSENumberList); String strPaymentMarketList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Payment Market')])[" + i + "]")) .getText(); strPaymentMarket.add(strPaymentMarketList); System.out.println("Displaying the Payment Market list :" + strPaymentMarketList); String strPaymentUnitList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Payment Unit')])[" + i + "]")) .getText(); strPaymentunit.add(strPaymentUnitList); System.out.println("Displaying the Payment Unit list :" + strPaymentUnitList); String strLiabilityUnitList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Unit')])[" + i + "]")) .getText(); strLiabilityUnit.add(strLiabilityUnitList); System.out.println("Displaying the Liability Unit list :" + strLiabilityUnitList); String strLiabilityCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Currency')])[" + i + "]")) .getText(); strLiabilityCurrency.add(strLiabilityCurrencyList); System.out.println("Displaying the Liability Currency list :" + strLiabilityCurrencyList); String strMarketCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Market Currency')])[" + i + "]")) .getText(); strMarketCurrency.add(strMarketCurrencyList); System.out.println("Displaying the Market Currency list :" + strMarketCurrencyList); String strInvoiceReleaseDateList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + j + "]")) .getText(); } else { strInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + i + "]")) .getText(); } strInvoiceReleaseDate.add(strInvoiceReleaseDateList); System.out .println("Displaying the Invoice release date list :" + strInvoiceReleaseDateList); String strUserIDList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'USER ID')])[" + i + "]")) .getText(); strUserId.add(strUserIDList); System.out.println("Displaying the UserId list :" + strUserIDList); } // for (int i = 0; i < products.size(); i++) { // System.out.println("############ CHECKING ########################"); // System.out.println(CommonData.strInvoiceNumber.get(i) + " Invoice Number"); // System.out.println(CommonData.strInvoiceReleaseDate.get(i) + " Invoice Release Date"); // System.out.println(CommonData.strTotalPayment.get(i) + " Total Payment"); // // } } else { System.out.println("MultiUserTest License is not displayed"); } driver.switchTo().defaultContent(); driver.close(); driver.switchTo().window(oldTab); // driver.get(" // http://148.173.174.122:8900/acadmin/?serverURL=http://wpqwa551:8000"); driver.get( "http://148.173.174.122:8900/acadmin/jobmanager.jsp?serverURL=http%3a%2f%2fwpqwa551%3a8000&volume=wpqwa551&daemonURL=http://wpqwa551:8100&daemonURL=http://wpqwa551:8100"); if (driver.findElement(By.xpath("//td[contains(text(),'System')]")).isDisplayed()) { System.out.println("--------------##### Focus Changed to old window #### -----------"); } else { System.out.println("---------Focus not changed---------------"); } driver.switchTo().defaultContent(); WebElement postframe = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(postframe); Thread.sleep(1200); if (driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).isDisplayed()) { try { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]"))); } catch (Exception e) { driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).click(); } System.out.println("Clicking on Completed Tabs"); } else { System.out.println("Failed:Unable to Find the Completed Tab section"); } Thread.sleep(5000); WebElement postframe1 = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(postframe1); String strPostValue = "MRF412"; driver.findElement(By.id("FilterText")).clear(); driver.findElement(By.id("FilterText")).sendKeys(strPostValue); Thread.sleep(1200); driver.findElement(By.xpath("//input[@value='Apply']")).click(); Thread.sleep(3500); WebElement postframe2 = driver.findElement(By.id("ifrListFrame")); driver.switchTo().frame(postframe2); String postoldTab = driver.getWindowHandle(); driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).click(); Thread.sleep(5000); ArrayList<String> newTab_1 = new ArrayList<String>(driver.getWindowHandles()); newTab_1.remove(postoldTab); // change focus to new tab driver.switchTo().window(newTab_1.get(0)); WebElement postframe3 = driver.findElement(By.id("reportframe")); driver.switchTo().frame(postframe3); System.out.println("-############## COMPARING PRE-REPORT and POST-REPORT-##############--"); // String strPostPageSource = driver.getPageSource(); String strPostPageTitle = driver.findElement(By.xpath("//div[contains(@id,'water')]")).getText(); if (strPostPageTitle.contains(CommonData.strPageTitle)) { System.out.println( "Passed : Page Title is matching with Pre-report and Post-Report " + strPostPageTitle); for (int i = 1, k = 0; i <= CommonData.strPartnerName.size(); i++, k++) { System.out.println( "----------------->>> COMPARING LIST OF TABLE VALUES FORM PRE-REPORT AND POST-REPORT ----------------------->>>: " + i); String strPostPartnerNameList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Partner Name')])[" + i + "]")) .getText(); if (CommonData.strPartnerName.get(k).contains(strPostPartnerNameList)) { System.out.println("Passed : Partner Name is matching with Pre-report and Post-Report :" + strPostPartnerNameList); } else { System.out.println( "Failed : Partner Name is not matching with Pre-report and Post-Report :" + strPostPartnerNameList); } String strPostInvoiceNumberList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Invoice Number')])[" + i + "]")) .getText(); if (CommonData.strInvoiceNumber.get(k).contains(strPostInvoiceNumberList)) { System.out.println( "Passed : Post Invoice Number is matching with Pre-report and Post-Report :" + strPostInvoiceNumberList); } else { System.out.println( "Failed : Post Invoice Number is not matching with Pre-report and Post-Report :" + strPostInvoiceNumberList); } String strPostTotalPaymentList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strPostTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + j + "]")) .getText(); if (CommonData.strTotalPayment.get(k).contains(strPostTotalPaymentList)) { System.out.println( "Passed : Total Payment List is matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } else { System.out.println( "Failed : Total Payment List is not matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } } else { strPostTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + i + "]")) .getText(); if (CommonData.strTotalPayment.get(k).contains(strPostTotalPaymentList)) { System.out.println( "Passed : Total Payment List is matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } else { System.out.println( "Failed : Total Payment List is not matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } } String strPostSENumberList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'SE Number')])[" + i + "]")) .getText(); if (CommonData.strSENumber.get(k).contains(strPostSENumberList)) { System.out .println("Passed : SE Number List is matching with Pre-report and Post-Report :" + strPostSENumberList); } else { System.out.println( "Failed : SE Number List is not matching with Pre-report and Post-Report :" + strPostSENumberList); } String strPostPaymentMarketList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Payment Market')])[" + i + "]")) .getText(); if (CommonData.strPaymentMarket.get(k).contains(strPostPaymentMarketList)) { System.out .println("Passed : Payment Market is matching with Pre-report and Post-Report :" + strPostPaymentMarketList); } else { System.out.println( "Failed : Payment Market is not matching with Pre-report and Post-Report :" + strPostPaymentMarketList); } String strPostPaymentUnitList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Payment Unit')])[" + i + "]")) .getText(); if (CommonData.strPaymentunit.get(k).contains(strPostPaymentUnitList)) { System.out.println( "Passed : Payment Unit list is matching with Pre-report and Post-Report :" + strPostPaymentUnitList); } else { System.out.println( "Failed : Payment Unit list is not matching with Pre-report and Post-Report :" + strPostPaymentUnitList); } String strPostLiabilityUnitList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Unit')])[" + i + "]")) .getText(); if (CommonData.strLiabilityUnit.get(k).contains(strPostLiabilityUnitList)) { System.out.println( "Passed : Liability Unit list is matching with Pre-report and Post-Report :" + strPostLiabilityUnitList); } else { System.out.println( "Failed : Liability Unit list is not matching with Pre-report and Post-Report :" + strPostLiabilityUnitList); } String strPostLiabilityCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Currency')])[" + i + "]")) .getText(); if (CommonData.strLiabilityCurrency.get(k).contains(strPostLiabilityCurrencyList)) { System.out.println( "Passed : Liability Currency list is matching with Pre-report and Post-Report :" + strPostLiabilityCurrencyList); } else { System.out.println( "Failed : Liability Currency list is not matching with Pre-report and Post-Report :" + strPostLiabilityCurrencyList); } String strPostMarketCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Market Currency')])[" + i + "]")) .getText(); if (CommonData.strMarketCurrency.get(k).contains(strPostMarketCurrencyList)) { System.out.println( "Passed : Market Currency list is matching with Pre-report and Post-Report :" + strPostMarketCurrencyList); } else { System.out.println( "Failed : Market Currency list is not matching with Pre-report and Post-Report :" + strPostMarketCurrencyList); } String strPostInvoiceReleaseDateList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strPostInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + j + "]")) .getText(); if (CommonData.strInvoiceReleaseDate.get(k).contains(strPostInvoiceReleaseDateList)) { System.out.println( "Passed : Invoice Release Date list is matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } else { System.out.println( "Failed : Invoice Release Date list is not matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } } else { strPostInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + i + "]")) .getText(); if (CommonData.strInvoiceReleaseDate.get(k).contains(strPostInvoiceReleaseDateList)) { System.out.println( "Passed : Invoice Release Date list is matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } else { System.out.println( "Failed : Invoice Release Date list is not matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } } String strPostUserIDList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'USER ID')])[" + i + "]")) .getText(); if (CommonData.strUserId.get(k).contains(strPostUserIDList)) { System.out.println("Passed : User ID list is matching with Pre-report and Post-Report :" + strPostUserIDList); } else { System.out.println( "Failed : User ID list is not matching with Pre-report and Post-Report :" + strPostUserIDList); } } driver.switchTo().defaultContent(); driver.close(); driver.switchTo().window(postoldTab); System.out.println( "########################## COMPLETED VALIDATIONS ALL ARE MATCHING ##################################"); } else { System.out.println("Failed : Page Title is not matching with Pre-report and Post-Report"); } } else { System.out.println("Failed to open the Multi user license page"); } } else { System.out.println("Unable to open the Files and folder page after login"); } driver.quit(); }
From source file:ca.pe.cjsigouin.testinator.selenium.WebDriverMain.java
public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "/home/krystofurr/Programs/selenium/geckodriver"); System.setProperty("webdriver.chrome.driver", "/home/krystofurr/Programs/selenium/chromedriver"); // WebDriver driver = new FirefoxDriver(); WebDriver driver = new ChromeDriver(); // WebDriver driver = new InternetExplorerDriver(); //Puts an Implicit wait, Will wait for 10 seconds before throwing exception driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); //Launch website driver.navigate().to(CommonConstants.HOST + CommonConstants.URL_LOGIN); driver.findElement(By.id("emailAddress")).sendKeys("cjsigouin@gov.pe.ca"); driver.findElement(By.id("password")).sendKeys("Test12345!"); driver.findElement(By.id("loginButton")).click(); WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(/* w w w.j av a 2s. com*/ ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='serviceWellSection']/div[2]/div/a/b"))); driver.get(CommonConstants.HOST + CommonConstants.URL_RESERVE_NAME_INTRO); WebDriverWait wait2 = new WebDriverWait(driver, 5); wait2.until(ExpectedConditions.elementToBeClickable(By.xpath(ReserveNameElement.INTRO_BUTTON_CANCEL))); driver.findElement(By.xpath(ReserveNameElement.INTRO_RADIO_RESERVE_NAME)).click(); // driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE)).sendKeys("Incorp"); Select dropdown = new Select(driver.findElement(By.xpath(ReserveNameElement.INTRO_SELECT_COMPANY_TYPE))); dropdown.selectByVisibleText("Incorporated"); driver.findElement(By.xpath(ReserveNameElement.INTRO_BUTTON_NEXT)).click(); // WebDriver driver = new FirefoxDriver(); // LoginTester login = new LoginTester(driver); // IncorporatedTester tester = new IncorporatedTester(driver); // // login.start(); // //Maximize the browser // driver.manage().window().maximize(); // tester.start(); // tester.stop(); // // Click on Math Calculators // driver.findElement(By.xpath(".//*[@id='hcalc']/table/tbody/tr/td[2]/div[3]/a")).click(); // // // Click on Percent Calculators // driver.findElement(By.xpath(".//*[@id='content']/ul[1]/li[3]/a")).click(); // // // Enter value 10 in the first number of the percent Calculator // driver.findElement(By.id("cpar1")).sendKeys(data.getNumberText(2)); // // // Enter value 50 in the second number of the percent Calculator // driver.findElement(By.id("cpar2")).sendKeys(data.getNumberText(2)); // // // Click Calculate Button // driver.findElement(By.xpath(".//*[@id='content']/table[1]/tbody/tr[2]/td/input[2]")).click(); // // // // Get the Result Text based on its xpath // String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/font/b")).getText(); // // // // Print a Log In message to the screen // System.out.println(" The Result is " + result); //Close the Browser. driver.close(); }