List of usage examples for org.openqa.selenium WebDriver quit
void quit();
From source file:akori.AKORI.java
public static void main(String[] args) throws IOException, InterruptedException { System.out.println("esto es AKORI"); URL = "http://www.mbauchile.cl"; PATH = "E:\\NetBeansProjects\\AKORI\\"; NAME = "mbauchile.png"; // Extrar DOM tree Document doc = Jsoup.connect(URL).timeout(0).get(); // The Firefox driver supports javascript WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); System.out.println(driver.manage().window().getSize().toString()); System.out.println(driver.manage().window().getPosition().toString()); int xmax = driver.manage().window().getSize().width; int ymax = driver.manage().window().getSize().height; // Go to the URL page driver.get(URL);/*from w ww .jav a 2 s. c o m*/ File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screen, new File(PATH + NAME)); BufferedImage img = ImageIO.read(new File(PATH + NAME)); //Graphics2D graph = img.createGraphics(); BufferedImage img1 = new BufferedImage(xmax, ymax, BufferedImage.TYPE_INT_ARGB); Graphics2D graph1 = img.createGraphics(); double[][] matrix = new double[ymax][xmax]; BufferedReader in = new BufferedReader(new FileReader("et.txt")); String linea; double max = 0; graph1.drawImage(img, 0, 0, null); HashMap<String, Integer> lista = new HashMap<String, Integer>(); int count = 0; for (int i = 0; (linea = in.readLine()) != null && i < 10000; ++i) { String[] datos = linea.split(","); int x = (int) Double.parseDouble(datos[0]); int y = (int) Double.parseDouble(datos[2]); long time = Double.valueOf(datos[4]).longValue(); if (x >= xmax || y >= ymax) continue; if (time < 691215) continue; if (time > 705648) break; if (lista.containsKey(x + "," + y)) lista.put(x + "," + y, lista.get(x + "," + y) + 1); else lista.put(x + "," + y, 1); ++count; } System.out.println(count); in.close(); Iterator iter = lista.entrySet().iterator(); Map.Entry e; for (String key : lista.keySet()) { Integer i = lista.get(key); if (max < i) max = i; } System.out.println(max); max = 0; while (iter.hasNext()) { e = (Map.Entry) iter.next(); String xy = (String) e.getKey(); String[] datos = xy.split(","); int x = Integer.parseInt(datos[0]); int y = Integer.parseInt(datos[1]); matrix[y][x] += (int) e.getValue(); double aux; if ((aux = normalMatrix(matrix, y, x, ((int) e.getValue()) * 4)) > max) { max = aux; } //normalMatrix(matrix,x,y,20); if (matrix[y][x] > max) max = matrix[y][x]; } int A, R, G, B, n; for (int i = 0; i < xmax; ++i) { for (int j = 0; j < ymax; ++j) { if (matrix[j][i] != 0) { n = (int) Math.round(matrix[j][i] * 100 / max); R = Math.round((255 * n) / 100); G = Math.round((255 * (100 - n)) / 100); B = 0; A = Math.round((255 * n) / 100); ; if (R > 255) R = 255; if (R < 0) R = 0; if (G > 255) G = 255; if (G < 0) G = 0; if (R < 50) A = 0; graph1.setColor(new Color(R, G, B, A)); graph1.fillOval(i, j, 1, 1); } } } //graph1.dispose(); ImageIO.write(img, "png", new File("example.png")); System.out.println(max); graph1.setColor(Color.RED); // Extraer elementos Elements e1 = doc.body().getAllElements(); int i = 1; ArrayList<String> tags = new ArrayList<String>(); for (Element temp : e1) { if (tags.indexOf(temp.tagName()) == -1) { tags.add(temp.tagName()); List<WebElement> query = driver.findElements(By.tagName(temp.tagName())); for (WebElement temp1 : query) { Point po = temp1.getLocation(); Dimension d = temp1.getSize(); if (d.width <= 0 || d.height <= 0 || po.x < 0 || po.y < 0) continue; System.out.println(i + " " + temp.nodeName()); System.out.println(" x: " + po.x + " y: " + po.y); System.out.println(" width: " + d.width + " height: " + d.height); graph1.draw(new Rectangle(po.x, po.y, d.width, d.height)); ++i; } } } graph1.dispose(); ImageIO.write(img, "png", new File(PATH + NAME)); driver.quit(); }
From source file:akori.Features.java
public static void main(String[] args) throws IOException, InterruptedException { URL = "http://www.mbauchile.cl"; Document doc = Jsoup.connect(URL).timeout(0).get(); WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(URL);/* ww w . j a va 2 s. c o m*/ Elements e1 = doc.body().getAllElements(); Element e = doc.body(); PrintWriter writer = new PrintWriter("features.txt", "UTF-8"); int i = 1; // String[][] matrix = new String[e1.size()][10]; // traverse(e, 1, 1, "", 1, writer, driver); ArrayList<String> tags = new ArrayList<String>(); System.out.println(""); // for (Element temp : e1) { // if (!temp.nodeName().equals("br")) { // writer.println(i + "," + temp.hashCode() + "," + temp.nodeName() + "," + temp.id()); // //System.out.println(i+","+temp.hashCode()+","+temp.nodeName()); // ++i; // } // } i = 1; for (Element temp : e1) { if (tags.indexOf(temp.tagName()) == -1) { tags.add(temp.tagName()); List<WebElement> query = driver.findElements(By.tagName(temp.tagName())); for (WebElement temp1 : query) { Point po = temp1.getLocation(); Dimension d = temp1.getSize(); if (d.width <= 0 || d.height <= 0 || po.x < 0 || po.y < 0) { continue; } if (temp1.getTagName().equals("img")) writer.println(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getAttribute("src")); else if (temp1.getTagName().equals("a")) writer.println(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getAttribute("href")); else writer.println(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getText()); ++i; } } } driver.quit(); writer.close(); }
From source file:akori.SELENIUM.java
public static void main(String[] args) throws Exception { // The Firefox driver supports javascript WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); System.out.println(driver.manage().window().getSize().toString()); System.out.println(driver.manage().window().getPosition().toString()); URL = "http://www.mbauchile.cl"; PATH = "E:\\NetBeansProjects\\AKORI\\1.png"; // Go to the Google Suggest home page driver.get(URL);/*from w ww . j av a2s . c o m*/ // Enter the query string "Cheese" WebElement query = driver.findElement(By.id("container")); Point p = query.getLocation(); Dimension d = query.getSize(); System.out.println("x: " + p.x + " y: " + p.y); System.out.println("width: " + d.width + " height: " + d.height); driver.quit(); }
From source file:application.Main.java
License:Open Source License
public static void appSingleThread(Globals GLOBALS) { LinkedList<String> list = Input.readFacebookPostIds(GLOBALS.FILENAME); if (GLOBALS.RANDOM) { Collections.shuffle(list); }//from ww w . jav a 2 s . co m String email = GLOBALS.fb_eamil; String pass = GLOBALS.password; WebDriver driver = new FirefoxDriver(); // The Firefox driver supports javascript Autenticate.perform(driver, email, pass); try { Thread.sleep(Globals.TIME_TO_LOGIN_IN_FB_MS); } catch (Exception ex) { System.out.println("InterruptedException in crawl.run()"); ex.printStackTrace(); System.exit(-1); } for (String post_id : list) { System.out.println("\n****** STARTING NEW TREE: " + post_id + "******"); try { //OPEN NEW TAB WebElement body = driver.findElement(By.tagName("body")); body.sendKeys(Keys.CONTROL + "t"); Tree post = new Tree(post_id, GLOBALS); boolean result = post.crawl(driver); if (result) { post.prune(); post.print(); post.printEdgeList(); System.out.println("****** TREE " + post_id + " ACCOMPLISHED ******"); } else { body.sendKeys(Keys.CONTROL + "w"); System.out.println("****** TREE " + post_id + " FAILED ******"); } //SWITCH TAB ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(tabs.size() - 1)); } catch (Exception e) { System.out.println("****** TREE " + post_id + " FAILED ******"); System.out.println("EXCEPTION in MAIN " + e); System.out.println("...RESTARTING APPLICATION AFTER 1 minute APPLICATION..."); driver.quit(); try { Thread.sleep(Globals.ONE_MINUTE); } catch (Exception ex) { System.out.println("InterruptedException in crawl.run()"); ex.printStackTrace(); System.exit(-1); } driver = new FirefoxDriver(); // The Firefox driver supports javascript Autenticate.perform(driver, email, pass); } } driver.quit(); }
From source file:at.ac.tuwien.big.testsuite.impl.selenium.BaseSeleniumTest.java
License:Apache License
@After public void destroy() throws Exception { Iterator<WebDriver> iter = webDrivers.iterator(); while (iter.hasNext()) { WebDriver webDriver = iter.next(); webDriver.quit(); iter.remove();/* w w w . j ava 2 s. c o m*/ } }
From source file:at.ac.tuwien.big.testsuite.impl.selenium.TableTest.java
License:Apache License
/** * Gameplay test - tests and simulates multiple game passes and exports the * page content at startup, after the first step and after a player has won * for the first time. Performed checks: - player and computer movement - * round count - leader - oily field reachable - player wins - computer wins * - restart// w w w . j a v a2 s . co m * * @throws Exception */ @Test public void testFeatures_shouldVerifyEveryFeatureAtLeastOnce() throws Exception { exportCurrentHTML(driver, "startup.html"); boolean firstStepExportDone = false; boolean finishExportDone = false; checkInitialState(driver, "Normal test"); OUTER: for (int i = 0; i < MAX_TRIES && (!jumpedOnOilyField || !onceLost || !onceWon); i++) { boolean finished = false; int noMovementRounds = 0; Integer expectedPosition = 0; Integer expectedComputerPosition = 0; Integer expectedRound = getRound(driver); checkThat("Round is wrong", expectedRound, isIn(Arrays.asList(0, 1))); if (expectedRound == null) { checkThat("Unexpected value for round", expectedRound, notNullValue()); expectedRound = 1; } for (int n = 0; n < MAX_MOVES && !finished; n++) { if (noMovementRounds >= NO_MOVEMENT_ROUNDS_THRESHOLD) { checkThat( "Can't play any more since the dice has either been disabled or can't be clicked anymore", true, is(false)); break OUTER; } Integer diceValue = rollDice(driver); Integer computerDiceValue = getComputerScore(driver); assertNotNull(TestsuiteConstants.KNOWN_ERROR_PREFIX + " Unexpected value for diceValue", diceValue); assertNotNull(TestsuiteConstants.KNOWN_ERROR_PREFIX + " Unexpected value for computerDiceValue", computerDiceValue); expectedRound++; // check dice value checkThat("Dice value '" + diceValue + "' is none of the allowed values {1, 2, 3}", diceValue, isIn(allowedDiceValues)); // check player move expectedPosition += diceValue; if (expectedPosition > 0 && expectedPosition < 6 && isOily(driver, expectedPosition) != null && isOily(driver, expectedPosition)) { jumpedOnOilyField = true; expectedPosition = 0; } if (expectedPosition > 6) { expectedPosition = 6; } // check computer move expectedComputerPosition += computerDiceValue; if (expectedComputerPosition > 0 && expectedComputerPosition < 6 && isOily(driver, expectedComputerPosition) != null && isOily(driver, expectedComputerPosition)) { jumpedOnOilyField = true; expectedComputerPosition = 0; } if (expectedComputerPosition > 6) { expectedComputerPosition = 6; } // Wait for the elements to appear in the expected positions if (!waitForJQuery(driver, By.xpath("//li[@id='" + getFieldId(expectedPosition) + "']//span[@id='player1']"))) { checkThat( "Could not retrieve position of player 1 by id 'player1' which might be caused by a concurrency error", true, is(false)); } if (!waitForJQuery(driver, By .xpath("//li[@id='" + getFieldId(expectedComputerPosition) + "']//span[@id='player2']"))) { checkThat( "Could not retrieve position of player 2 by id 'player2' which might be caused by a concurrency error", true, is(false)); } // check round Integer round = getRound(driver); assertNotNull(TestsuiteConstants.KNOWN_ERROR_PREFIX + " Unexpected value for round", round); checkThat("Round count of " + round + " is not as expected (" + expectedRound + ")", round, is(expectedRound)); if (!firstStepExportDone) { exportCurrentHTML(driver, "first_step.html"); firstStepExportDone = true; } Integer position = getPlayerPosition(driver, 1); Integer computerPosition = getPlayerPosition(driver, 2); assertNotNull(TestsuiteConstants.KNOWN_ERROR_PREFIX + " Unexpected value for position", position); assertNotNull(TestsuiteConstants.KNOWN_ERROR_PREFIX + " Unexpected value for computerPosition", computerPosition); checkThat("Incorrect Player position: " + position + " (expected: " + expectedPosition + ")", position, is(expectedPosition)); checkThat("Incorrect Computer position: " + computerPosition + " (expected: " + expectedComputerPosition + ")", computerPosition, is(expectedComputerPosition)); if (((position == expectedPosition - diceValue && isOily(driver, position + diceValue) != null && !isOily(driver, position + diceValue)) || (expectedPosition == 0 && isOily(driver, position + diceValue) != null && isOily(driver, position + diceValue))) && ((computerPosition == expectedComputerPosition - computerDiceValue && isOily(driver, computerPosition + computerDiceValue) != null && !isOily(driver, computerPosition + computerDiceValue)) || (expectedComputerPosition == 0 && isOily(driver, computerPosition + computerDiceValue) != null && isOily(driver, computerPosition + computerDiceValue))) && round == expectedRound - 1) { noMovementRounds++; } // do this so that even if students do something wrong, we don't have to wait for coming timeouts expectedPosition = position; expectedComputerPosition = computerPosition; expectedRound = round; // check leader String expectedLeader = "mehrere"; if (position > computerPosition) { expectedLeader = getPlayerName(driver, 1).toLowerCase(); } else if (position < computerPosition) { expectedLeader = getPlayerName(driver, 2).toLowerCase(); } String leader = getLeader(driver); checkThat("Incorrect Leader: " + leader + " (expected: " + expectedLeader + ") because player position is " + position + " and computer position is " + computerPosition, leader, is(expectedLeader)); if (position == 6) { onceWon = true; finished = true; } if (computerPosition == 6) { onceLost = true; finished = true; } if (!multipleTested && (position != 0 || computerPosition != 0)) { multipleTested = true; WebDriver secondDriver = null; try { secondDriver = createDriver(); checkInitialState(secondDriver, "Concurrent test"); } finally { if (secondDriver != null) { secondDriver.quit(); } } } } if (!finishExportDone && finished) { exportCurrentHTML(driver, "finish.html"); finishExportDone = true; } // try to restart startNewGame(driver); Integer player1Position = getPlayerPosition(driver, 1); Integer player2Position = getPlayerPosition(driver, 2); checkThat("Player position not 0 after restart", player1Position, is(0)); checkThat("Computer position not 0 after restart", player2Position, is(0)); if (player1Position == null || player1Position != 0 || player2Position == null || player2Position != 0) { break; } } checkThat("Oily field never reached", jumpedOnOilyField, is(true)); checkThat("Concurrent test could not be executed", multipleTested, is(true)); checkThat("Player couldn't win at least once after " + MAX_TRIES + " games", onceLost, is(true)); checkThat("Computer couldn't win at least once after " + MAX_TRIES + " games", onceWon, is(true)); }
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);// w w w . j a v a2 s . c om 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); // } // // // 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:br.edu.ifpb.praticas.testSystem.FilmeTest.java
@Test public void testCadastro() throws Exception { WebDriver driver = new FirefoxDriver(); WebElement element = driver.findElement(By.name("nome")); // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. assertEquals("http://localhost:8085/SisFilme/index.xhtml", driver.getCurrentUrl()); Thread.sleep(2000L);/* ww w.ja v a 2 s .c o m*/ element = driver.findElement(By.name("nome")); element.sendKeys("007 contra moscol"); element = driver.findElement(By.name("nome")); element.sendKeys("007 contra moscol"); element = driver.findElement(By.name("ano")); element.sendKeys("2014"); element = driver.findElement(By.name("genero")); element = driver.findElement(By.name("nota")); element.sendKeys("2"); element = driver.findElement(By.name("salvar")); Thread.sleep(2000L); element.click(); assertEquals("http://localhost:8085/SisFilme/gerenciamento.xhtml", driver.getCurrentUrl()); assertNotNull(element); // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return d.getTitle().contains("NetBeans"); } }); //Close the browser driver.quit(); }
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/*w w w. jav a 2s. 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);/*w w w . j av a 2 s .co 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(); }