List of usage examples for org.openqa.selenium WebDriver close
void close();
From source file:RegisterCH.java
public static void main(String[] args) throws InterruptedException { // Optional, if not specified, WebDriver will search your path for Chrome driver System.setProperty("webdriver.chrome.driver", "/Users/tatianakesler/Desktop/Selenium/chromedriver"); WebDriver wd = new ChromeDriver(); wd.get(baseURL);/*w w w . j a va 2s . com*/ wd.manage().window().maximize(); //@CONSUMER_NO_BOAT_REG //Click SignUp as a consumer wd.findElement(By.id("btnRegister")).click(); wd.findElement(By.id("personalTab")).click(); //Type 1st, last , display name wd.findElement(By.id("FirstNameOwner")).sendKeys(new String[] { Name1 }); wd.findElement(By.id("LastNameOwner")).sendKeys(new String[] { Last1 }); wd.findElement(By.id("DisplayNameOwner")).sendKeys(new String[] { DisplayName1 }); //Type in email and confirm email wd.findElement(By.id("EmailOwner")).sendKeys(new String[] { Email1 }); wd.findElement(By.id("EmailConfirmOwner")).sendKeys(new String[] { Email1 }); //Type in Password and confirm password wd.findElement(By.id("PasswordOwner")).sendKeys(new String[] { Pass }); wd.findElement(By.id("PasswordConfirmOwner")).sendKeys(new String[] { Pass }); //Type a zip code wd.findElement(By.id("ZipCodeOwner")).sendKeys(new String[] { "33480" }); //Uncheck im a boat Owner wd.findElement(By.id("IsBoatOwner")).click(); //Check terms of use wd.findElement(By.id("termsOfUse")).click(); //Click SignUp wd.findElement(By.id("btnSaveData")).click(); Thread.sleep(7000); //Verify My Stuff tab //Verify client's name if (wd.getPageSource().contains(DisplayName1)) { System.out.println("- Client (No boat) Registered - PASS "); System.out.println("- Client name verified - " + DisplayName1 + " - PASS "); } else { System.out.println("- Client name verified - " + DisplayName1 + " - FAIL "); } //Verify My Stuff tab if (wd.getPageSource().contains("My Stuff")) { System.out.println("- My Stuff tab verified (no boat) - PASS "); } else { System.out.println("- My Stuff tab not found (no boat) - FAIL "); } //Close pop-up and logout and Logout if (wd.getPageSource().contains("glyphicon glyphicon-remove-circle")) { wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click(); //Logout(); Actions action1 = new Actions(wd); WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName")); Thread.sleep(3000); WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action1.moveToElement(elems01).click().perform(); Thread.sleep(2000); action1.moveToElement(elems001).click().perform(); } else { //Logout(); Actions action1 = new Actions(wd); WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName")); Thread.sleep(3000); WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action1.moveToElement(elems01).click().perform(); Thread.sleep(2000); action1.moveToElement(elems001).click().perform(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CONSUMER WITH BOAT REG //wd.get("http://qa.app.mytaskit.com"); //Click SignUp as a consumer wd.findElement(By.id("btnRegister")).click(); wd.findElement(By.id("personalTab")).click(); //Type 1st, last , display name wd.findElement(By.id("FirstNameOwner")).sendKeys(new String[] { Name1 }); wd.findElement(By.id("LastNameOwner")).sendKeys(new String[] { Last1 }); wd.findElement(By.id("DisplayNameOwner")).sendKeys(new String[] { DisplayName2 }); //Type in email and confirm email wd.findElement(By.id("EmailOwner")).sendKeys(new String[] { Email2 }); wd.findElement(By.id("EmailConfirmOwner")).sendKeys(new String[] { Email2 }); //Type in Password and confirm password wd.findElement(By.id("PasswordOwner")).sendKeys(new String[] { Pass }); wd.findElement(By.id("PasswordConfirmOwner")).sendKeys(new String[] { Pass }); //Type a zip code wd.findElement(By.id("ZipCodeOwner")).sendKeys(new String[] { "33480" }); //Type in boat info wd.findElement(By.id("BoatName")).sendKeys(new String[] { "Boat_automation" }); wd.findElement(By.id("BoatManufacturer")).sendKeys(new String[] { "Volvo" }); wd.findElement(By.id("BoatLength")).sendKeys(new String[] { "35" }); //Check terms of use wd.findElement(By.id("termsOfUse")).click(); //Click SignUp wd.findElement(By.id("btnSaveData")).click(); Thread.sleep(7000); //Verify client's name if (wd.getPageSource().contains(DisplayName2)) { System.out.println("- Client boat owner Registered, client name verified - PASS "); System.out.println("- Client name verified - " + DisplayName2 + " - PASS "); } else { System.out.println("- Client no boat name shows up on the TM page " + DisplayName2 + " - Fail "); } //Verify My Stuff tab if (wd.getPageSource().contains("My Stuff")) { System.out.println("- My Stuff tab verified (boat owner) - PASS "); } else { System.out.println("- My Stuff tab not found (boat owner) - FAIL "); } //Close pop-up and logout and Logout // if(wd.getPageSource().contains("glyphicon glyphicon-remove-circle")) // { // wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click(); // // //Logout(); // Actions action2 = new Actions(wd); // WebElement elems02 = wd.findElement(By.id("navTopRightMenuDisplayName")); // Thread.sleep(3000); // WebElement elems002 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); // action2.moveToElement(elems02).click().perform(); // Thread.sleep(2000); // action2.moveToElement(elems002).click().perform(); // // } // else // { //Logout(); Actions action2 = new Actions(wd); WebElement elems02 = wd.findElement(By.id("navTopRightMenuDisplayName")); Thread.sleep(3000); WebElement elems002 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action2.moveToElement(elems02).click().perform(); Thread.sleep(2000); action2.moveToElement(elems002).click().perform(); // } //FREE BUSINESS REGISTRATION //Launch URL //Click SignUp as a business wd.findElement(By.id("btnRegister")).click(); wd.findElement(By.id("businessTab")).click(); //Type 1st, last , display name wd.findElement(By.id("BusinessNameBiz")).sendKeys(new String[] { DisplayName3 }); wd.findElement(By.id("DisplayNameBiz")).sendKeys(new String[] { DisplayName3 }); //Type a ZIP code wd.findElement(By.id("ZipCodeBiz")).sendKeys(new String[] { "33480" }); //Check Business type check-boxes wd.findElement(By.id("TypeIsBoatBuilder")).click(); wd.findElement(By.id("TypeIsServiceYard")).click(); wd.findElement(By.id("TypeIsYachtManagementCompany")).click(); wd.findElement(By.id("TypeIsYachtManagementCompany")).click(); wd.findElement(By.id("TypeIsEquipmentSupplier")).click(); //Type in Administrator's 1st Name, last name wd.findElement(By.id("FirstNameBiz")).sendKeys(new String[] { Name1 }); wd.findElement(By.id("LastNameBiz")).sendKeys(new String[] { Last1 }); //Type in email and confirm email wd.findElement(By.id("EmailBiz")).sendKeys(new String[] { Email3 }); wd.findElement(By.id("EmailConfirmBiz")).sendKeys(new String[] { Email3 }); //Type in Password and confirm password wd.findElement(By.id("PasswordBiz")).sendKeys(new String[] { Pass }); wd.findElement(By.id("PasswordConfirmBiz")).sendKeys(new String[] { Pass }); //Check terms of use wd.findElement(By.id("termsOfUse")).click(); //Click SignUp wd.findElement(By.id("btnSaveData")).click(); Thread.sleep(3000); //Verify that is is a free business account if (wd.getPageSource().contains("Get Professional")) { System.out.println("- Free Business Registration - PASS "); System.out.println("- Get Professional button verified - PASS "); } else { System.out.println("- Free Business was NOT registered " + DisplayName3 + " - Fail "); System.out.println("- Get Professional button NOT verified - PASS "); } //Verify user name if (wd.getPageSource().contains(DisplayName3)) { System.out.println("- Free Business name verified - " + DisplayName3 + " - PASS "); } else { System.out.println("- User name not verified " + DisplayName3 + " - Fail "); } //Close pop-up and logout and Logout // if(wd.getPageSource().contains("glyphicon glyphicon-remove-circle")) //Logout(); Actions action1 = new Actions(wd); WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName")); Thread.sleep(3000); WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action1.moveToElement(elems01).click().perform(); Thread.sleep(2000); action1.moveToElement(elems001).click().perform(); // } // FREE BUSINSS UPGRADE TO PRO option 1 -Annual //Launch URL // wd.get("http://qa.app.mytaskit.com"); //Thread.sleep(3000); //Login as free business wd.findElement(By.id("login_email")).sendKeys(new String[] { Email3 }); wd.findElement(By.id("login_password")).sendKeys(new String[] { Pass }); wd.findElement(By.xpath("//*[contains(text(), 'Login')]")).click(); Thread.sleep(3000); //Close pop-up and logout and Logout //Click Upgrade to Pro wd.findElement(By.id("getProfessionalBtn")).click(); //-----------------------------UPGRADE TO PRO //Type in PROMO CODE and click Apply wd.findElement(By.id("promo-code")).sendKeys(new String[] { "mvf&f" }); wd.findElement(By.id("btnVerify")).click(); Thread.sleep(3000); //Select licenses wd.findElement(By.id("licenses")).sendKeys(new String[] { "25" }); //Select Billing Cycle and Payment Details - Annual wd.findElement(By.id("billing-cycle-2")).click(); //Type in address / Phone wd.findElement(By.id("addManualAddress_addressLookup")).click(); //Street address wd.findElement(By.id("address")).sendKeys(new String[] { "1115 45th Street" }); //City wd.findElement(By.id("city")).sendKeys(new String[] { "West Palm Beach" }); //Country wd.findElement(By.id("CountrySelect")).sendKeys(new String[] { "United States" }); //ZIP CODE wd.findElement(By.id("zip-code")).sendKeys(new String[] { "33407" }); //State wd.findElement(By.id("StateSelect")).sendKeys(new String[] { "FL" }); //Phone wd.findElement(By.id("phone")).sendKeys(new String[] { "1234567890" }); // Click submit payment wd.findElement(By.id("btnEnroll")).click(); //Close Grid Modal //wd.findElement(By.xpath("/html/body/div[10]/div/div/div[3]/div/button[1]")).click(); Thread.sleep(2000); //Verify that Boat has been added if (wd.getPageSource().contains("Get Professional")) { System.out.println("- Free business Upgrade to PRO (Annual) - FAIL"); } else { System.out.println("- Free business Upgrade to PRO (Annual) - PASS"); } Actions action3 = new Actions(wd); WebElement elems03 = wd.findElement(By.id("navTopRightMenuDisplayName")); WebElement elems003 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action3.moveToElement(elems03).click().perform(); Thread.sleep(2000); action3.moveToElement(elems003).click().perform(); Thread.sleep(4000); /////////////////SELECT DIFFERENT PRICE OPTIONS///////////////////////////////////////////////////////////////////////////////////////////////////////// //SELECT DIFFERENT PRICE OPTIONS //Launch URL //Click SignUp as a business wd.findElement(By.id("btnRegister")).click(); wd.findElement(By.id("businessTab")).click(); //Type 1st, last , display name wd.findElement(By.id("BusinessNameBiz")).sendKeys(new String[] { DisplayName4 }); wd.findElement(By.id("DisplayNameBiz")).sendKeys(new String[] { DisplayName4 }); //Type a ZIP code wd.findElement(By.id("ZipCodeBiz")).sendKeys(new String[] { "33480" }); //Check Business type check-boxes wd.findElement(By.id("TypeIsBoatBuilder")).click(); wd.findElement(By.id("TypeIsServiceYard")).click(); wd.findElement(By.id("TypeIsYachtManagementCompany")).click(); wd.findElement(By.id("TypeIsYachtManagementCompany")).click(); wd.findElement(By.id("TypeIsEquipmentSupplier")).click(); //Type in Administrator's 1st Name, last name wd.findElement(By.id("FirstNameBiz")).sendKeys(new String[] { Name1 }); wd.findElement(By.id("LastNameBiz")).sendKeys(new String[] { Last1 }); //Type in email and confirm email wd.findElement(By.id("EmailBiz")).sendKeys(new String[] { Email4 }); wd.findElement(By.id("EmailConfirmBiz")).sendKeys(new String[] { Email4 }); //Type in Password and confirm password wd.findElement(By.id("PasswordBiz")).sendKeys(new String[] { Pass }); wd.findElement(By.id("PasswordConfirmBiz")).sendKeys(new String[] { Pass }); //Check terms of use wd.findElement(By.id("termsOfUse")).click(); //Click SignUp wd.findElement(By.id("btnSaveData")).click(); Thread.sleep(3000); //Close pop-up and logout and Logout // wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click(); //////////////////UPGRADE///////////////////////////////////////////////////////////////////////////////////////// Thread.sleep(2000); //Click Upgrade to Pro wd.findElement(By.id("getProfessionalBtn")).click(); //-----------------------------UPGRADE TO PRO Thread.sleep(3000); //Type in PROMO CODE and click Apply wd.findElement(By.id("promo-code")).sendKeys(new String[] { "mvf&f" }); wd.findElement(By.id("btnVerify")).click(); Thread.sleep(3000); //Select licenses wd.findElement(By.id("licenses")).sendKeys(new String[] { "15" }); //Select Billing Cycle and Payment Details - Annual wd.findElement(By.id("billing-cycle-1")).click(); //Type in address / Phone wd.findElement(By.id("addManualAddress_addressLookup")).click(); //Street address wd.findElement(By.id("address")).sendKeys(new String[] { "1115 45th Street" }); //City wd.findElement(By.id("city")).sendKeys(new String[] { "West Palm Beach" }); //Country wd.findElement(By.id("CountrySelect")).sendKeys(new String[] { "United States" }); //ZIP CODE wd.findElement(By.id("zip-code")).sendKeys(new String[] { "33407" }); //State wd.findElement(By.id("StateSelect")).sendKeys(new String[] { "FL" }); //Phone wd.findElement(By.id("phone")).sendKeys(new String[] { "1234567890" }); // Click submit payment wd.findElement(By.id("btnEnroll")).click(); Thread.sleep(4000); //Verify that Boat has been added if (wd.getPageSource().contains("Get Professional")) { System.out.println("- Free Business upgrade to PRO (Monthly) - FAIL"); } else { System.out.println("- Free Business upgrade to PRO (Monthly) - PASS"); } Thread.sleep(2000); Actions action6 = new Actions(wd); WebElement elems06 = wd.findElement(By.id("navTopRightMenuDisplayName")); WebElement elems006 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]")); action6.moveToElement(elems06).click().perform(); Thread.sleep(2000); action6.moveToElement(elems006).click().perform(); Thread.sleep(5000); wd.close(); }
From source file:ClientServicesQA.java
public void loginToClientServices(String url, WebDriver driver) throws InterruptedException { String institutionName = "Client Services"; String userName = "MHCampusAutomationAdmin"; String password = "12345678"; driver.manage().window().maximize(); driver.get(url);//from ww w . j ava2 s .c om driver.findElement(By.id("TextBoxInstitution")).clear(); // clearing the institution text box driver.findElement(By.id("TextBoxInstitution")).sendKeys(institutionName); // enter institution name driver.findElement(By.id("TextBoxUsername")).clear(); // enter user name driver.findElement(By.id("TextBoxUsername")).sendKeys(userName);// clearing the user name text box driver.findElement(By.id("TextBoxPassword")).clear(); // enter password driver.findElement(By.id("TextBoxPassword")).sendKeys(password);// clearing the password text box driver.findElement(By.id("ButtonLogin")).click(); //Clicking on the Login button Thread.sleep(2000); //driver.findElement(By.partialLinkText("Convert")).click(); // find element by partial text //driver.findElement(By.id("ctl00_LoginStatus1")).click(); driver.close(); }
From source file:ClientServicesQA.java
public void createNewTegrityCustomer(WebDriver driver) throws Exception { driver.findElement(By.linkText("Create Tegrity customer")).click(); Thread.sleep(2000);/*from ww w.ja va2s .c o m*/ driver.close(); }
From source file:TestWriteanArticle.java
@org.junit.Test public void positive() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);/*from w w w . ja va 2 s.c o m*/ WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use selenium"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("Are any of these topics the same as yours?")); webDriver.close(); }
From source file:TestWriteanArticle.java
@org.junit.Test public void negative() throws InterruptedException { System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe"); WebDriver webDriver = new FirefoxDriver(); String page = "http://www.wikihow.com/Special:CreatePage"; webDriver.get(page);/*from w ww. j ava2 s . c o m*/ WebElement title = webDriver.findElement(By.id("cp_title_input")); title.sendKeys("how to use wikiHow"); webDriver.findElement(By.id("cp_title_btn")).click(); Thread.sleep(10); WebDriverWait wait = new WebDriverWait(webDriver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr"))); assertTrue(webDriver.getPageSource().contains("That article already exists!")); webDriver.close(); }
From source file:FirefoxConsoleExportTest.java
License:Open Source License
@org.junit.Test public void testLogger() throws Exception { FirefoxConsoleExport test = new FirefoxConsoleExport(9999); WebDriver driver = test.getDriver(); driver.get("https://slashdot.org"); ArrayList<LogEntry> logs = test.getLogEntries(); driver.close(); System.out.println(logs);// w w w. j a v a 2s . c o m assertTrue("No console logs were created from slashdot.", logs.size() > 0); }
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 www . j a va 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 ww .j a va2s. c om 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(); }
From source file:cn.edu.hfut.dmic.webcollector.example.FirefoxSelenium3.java
License:Open Source License
public static void main(String[] args) throws Exception { Executor executor = new Executor() { @Override//from www . ja v a 2s .c om public void execute(CrawlDatum datum, CrawlDatums next) throws Exception { MongoClient mongoClient = new MongoClient("localhost", 27017); // ? // DBCollection dbCollection = mongoClient.getDB("maoyan_crawler").getCollection("rankings_am"); DB db = mongoClient.getDB("maoyan_crawler"); // ????? Set<String> colls = db.getCollectionNames(); for (String s : colls) { // Collection(?"") if (s.equals("attend_rate")) { db.getCollection(s).drop(); } } DBCollection dbCollection = db.getCollection("attend_rate"); ProfilesIni pi = new ProfilesIni(); FirefoxProfile profile = pi.getProfile("default"); WebDriver driver = new FirefoxDriver(profile); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS); // driver.setJavascriptEnabled(false); driver.get(datum.getUrl()); // System.out.println(driver.getPageSource()); driver.findElement(By.xpath("//*[@id='seat_city']")).click(); driver.switchTo().window(driver.getWindowHandle()); int city_num = driver.findElements(By.xpath("//div[@id='all-citys']/div/ul/li/a")).size(); for (int i = 0; i < city_num; i++) { System.out.println("A city chosen" + i); System.out.println( driver.findElements(By.xpath("//div[@id='all-citys']/div/ul/li/a")).get(i).getText()); String city = driver.findElements(By.xpath("//div[@id='all-citys']/div/ul/li/a")).get(i) .getText(); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", driver.findElements(By.xpath("//div[@id='all-citys']/div/ul/li/a")).get(i)); ((JavascriptExecutor) driver).executeScript("window.scrollBy(0, -250)", ""); Thread.sleep(1000); new Actions(driver) .moveToElement( driver.findElements(By.xpath("//div[@id='all-citys']/div/ul/li/a")).get(i)) .click().perform(); driver.switchTo().window(driver.getWindowHandle()); // System.out.println(driver.findElement(By.xpath("//span[@class='today']/em")).getText()); System.out.println(driver.findElement(By.xpath("//span[@class='today']")).getText()); for (int j = 0; j < driver .findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c1 lineDot']")) .size(); j++) { System.out.println(driver .findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c1 lineDot']")) .get(j).getText()); System.out.println( driver.findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c2 red']")) .get(j).getText()); System.out.println( driver.findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c3 gray']")) .get(j).getText()); BasicDBObject dbObject = new BasicDBObject(); dbObject.append("title", driver.findElement(By.xpath("//span[@class='today']")).getText()) .append("city", city) .append("mov_cnname", driver.findElements( By.xpath("//div[@id='seat_table']//ul//li[@class='c1 lineDot']")) .get(j).getText()) .append("boxoffice_rate", driver .findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c2 red']")) .get(j).getText()) .append("visit_pershow", driver .findElements(By.xpath("//div[@id='seat_table']//ul//li[@class='c3 gray']")) .get(j).getText()); dbCollection.insert(dbObject); } System.out.println("new city list to choose"); new Actions(driver).moveToElement(driver.findElement(By.xpath("//*[@id='seat_city']"))).click() .perform(); driver.switchTo().window(driver.getWindowHandle()); Thread.sleep(500); } driver.close(); driver.quit(); mongoClient.close(); } }; //DBDBManager DBManager manager = new BerkeleyDBManager("crawl"); //Crawler?DBManagerExecutor Crawler crawler = new Crawler(manager, executor); crawler.addSeed("http://pf.maoyan.com/attend/rate"); crawler.start(1); }
From source file:com.amolik.scrapers.OdishaRationCardScraper.java
public static void main(String[] args) throws Exception { ;/*from ww w . j a v a 2s .c o m*/ // The Firefox driver supports javascript WebDriver driver = new FirefoxDriver(); driver.get(AmolikProperties.getProperty("odisha_ration.startUrl")); baseDir = AmolikProperties.getProperty("odisha_ration.baseDir"); excelTemplateFileName = AmolikProperties.getProperty("odisha_ration.excelTemplateFileName"); excelFileExtension = AmolikProperties.getProperty("odisha_ration.excelExtension"); if (logger.isInfoEnabled()) { logger.info("startUrl=" + AmolikProperties.getProperty("odisha_ration.startUrl")); } processAllDistricts(driver); if (driver != null) { driver.close(); } }