List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:scormADL12.java
License:Open Source License
/** * Open TestSuite and Moodle site// w w w . j a v a 2 s. c o m * @throws IOException */ public void testSetup() throws IOException { String testSuiteURL = System.getProperty("testSuiteURL"); String moodleURL = System.getProperty("moodleURL"); if (testSuiteURL == null) { throw new IOException("ADL SCORM 1.2 Test Suite URL not specified"); } if (moodleURL == null) { throw new IOException("Moodle Test Site URL not specified"); } driver.get(testSuiteURL); driver.switchTo().frame("instructions"); driver.findElement(By.id("pname")).sendKeys("Moodle"); driver.findElement(By.id("pversion")).sendKeys("2.3"); driver.findElement(By.id("pvname")).sendKeys("MoodleHQ"); driver.findElement(By.id("continue01")).click(); ((JavascriptExecutor) driver).executeScript("window.open('" + moodleURL + "', 'moodleWindow');"); driver.switchTo().window("moodleWindow"); }
From source file:scormADL12.java
License:Open Source License
/** * Login into ADL SCORM Test Course/*www . j av a2 s . co m*/ * @param course */ public void loginCourse(int course) { driver.findElement(By.linkText("SCORM 1.2 ADL Test course")).click(); wait.until(presenceOfElementLocated(By.id("username"))); driver.findElement(By.id("username")).clear(); driver.findElement(By.id("password")).clear(); if (course != 2) { driver.findElement(By.id("username")).sendKeys("joestudent"); driver.findElement(By.id("password")).sendKeys("joestudent"); } else { driver.findElement(By.id("username")).sendKeys("marylearner"); driver.findElement(By.id("password")).sendKeys("marylearner"); } driver.findElement(By.id("loginbtn")).click(); wait.until(presenceOfElementLocated(By.xpath("//span[text()='LMSTestCourse01']"))); if (course != 1) { driver.findElement(By.xpath("//span[text()='LMSTestCourse02']")).click(); } else { driver.findElement(By.xpath("//span[text()='LMSTestCourse01']")).click(); } }
From source file:scormADL12.java
License:Open Source License
/** * Test all SCOes/*from w w w. j a va 2s .co m*/ * @param mode * @param course * @param scoLeft */ public void testSCO(char mode, int course, int scoLeft) { wait.until(presenceOfElementLocated(By.id("n"))); String url = driver.getCurrentUrl(); if (mode == 'b') { driver.findElement(By.id("b")).click(); } else { driver.findElement(By.id("n")).click(); } driver.findElement(By.xpath("//input[@value='Enter']")).click(); wait.until(presenceOfElementLocated(By.id("ygtvcontentel2"))); wait.until(presenceOfElementLocated(By.id("scorm_object"))); System.out.println("SCO Loaded. Testing ..."); long t0, t1; t0 = System.currentTimeMillis(); do { t1 = System.currentTimeMillis(); } while (t1 - t0 < 2000); driver.switchTo().frame("scorm_object"); if ((course == 1 && currentSCO != 4) || (course == 2 && currentSCO != 2)) { wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'This SCO Test Completed.')]"))); } else if ((course == 1 && currentSCO == 4) || (course == 2 && currentSCO == 2)) { //for both course 1 and course 2 if (scoLeft != 0) { wait.until(presenceOfElementLocated( By.xpath("//*[contains(.,'Please Log out and re-login to the LMS.')]"))); return; } else { wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'This SCO Test Completed.')]"))); } } System.out.println(driver.findElement(By.id("teststatus")).getText()); currentSCO++; driver.get(url); }
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);/* ww w .j av a 2s .c om*/ 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:OrdenReaprovisionamientoTest.java
@Test public void testCreateProveedor() throws Exception { /**//from ww w . jav a 2 s .c o m * Comando que realiza click sobre el boton "create" del toolbar. La * funcin 'find' encuentra el control y posteriormente hace clic en el * mismo. La forma en la que se busca el control es utilizando * expresiones xPath ya que los id de los mismos nunca son iguales (se * generan con junto con el valor de componentId que vara). */ driver.findElement(By.xpath("//button[contains(@id,'createButton')]")).click(); /** * Comando que duerme el Thread del test por 2 segundos para dejar que * el efecto 'slide down' de backbone abra el formulario de createSport. */ Thread.sleep(2000); /** * Comando que busca el elemento 'name' en el html actual. * Posteriormente limpia su contenido (comando clean). */ driver.findElement(By.id("name")).clear(); /** * Comando que simula la escritura de un valor en el elemento(sendKeys) * con el String de parmetro sobre // el elemento encontrado. */ driver.findElement(By.id("name")).sendKeys(name1); //Comandos para llenar el campo fecha driver.findElement(By.id("fecha")).clear(); driver.findElement(By.id("fecha")).sendKeys(fecha1); //Comando para seleccionar el checkbox // driver.findElement(By.id("esPerecedero")).click(); /** * Comandos para llenar el campo cantidad */ driver.findElement(By.id("cantidad")).clear(); driver.findElement(By.id("cantidad")).sendKeys(cantidad1); /** * Comandos para llenar el campo nombreProducto */ driver.findElement(By.id("nombreProducto")).clear(); driver.findElement(By.id("nombreProducto")).sendKeys(nombreProducto1); /** * Comando que encuentra y hace clic sobre el boton "Save" del toolbar * (una vez mas encontrado por una expresin Xpath) */ driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); /** * Comando que duerme el thread para esperar el efecto de slide down que * abre la lista */ Thread.sleep(2000); /** * Comando que obtiene el div azul de creacin exitosa. Si se obtiene, * la prueba va bien, si no, saldr un error y la prueba quedar como * fllida. */ WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); /** * Comando que obtiene la tabla con el elemento que se cre * anteriormente. */ List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean sucess = false; /** * Se itera sobre los elementos de la tabla para ver si el nuevo * elemento creado est en la lista */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name1) && Integer.parseInt( elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha1.split("/")[0])) && Integer.parseInt( elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha1.split("/")[1])) && Integer.parseInt( elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha1.split("/")[2])) && elems.get(2).getText().equals(cantidad1) && elems.get(3).getText().equals(nombreProducto1)) { /** * si se encuentra la fila, la variable 'fail' pasa a true, * indicando que el elemento creado esta en la lista. */ sucess = true; } } /** * la prueba es exitosa si se encontr el dialogo de creacin exitosa y * el nuevo elemento est en la lista. */ assertTrue(dialog != null && sucess); }
From source file:OrdenReaprovisionamientoTest.java
@Test public void testUpdateProveedor() throws Exception { /**//w ww . j a v a2s .com * Se hace clic en el vinculo "Edit" del primer elemento de la lista de * sports */ driver.findElement(By.linkText("Editar")).click(); Thread.sleep(2000); /** * Se realiza el mismo proceso de diligenciamento de los campos con los * cambios */ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys(name2); driver.findElement(By.id("fecha")).clear(); driver.findElement(By.id("fecha")).sendKeys(fecha2); driver.findElement(By.id("cantidad")).clear(); driver.findElement(By.id("cantidad")).sendKeys(cantidad2); driver.findElement(By.id("nombreProducto")).clear(); driver.findElement(By.id("nombreProducto")).sendKeys(nombreProducto2); driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); Thread.sleep(2000); /** * Se verifica que en la lista de respuesta hallan aparecido los cambios * en el elemento y tambin el mensaje de edicin exitosa. */ WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2) && Integer.parseInt( elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha2.split("/")[0])) && Integer.parseInt( elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha2.split("/")[1])) && Integer.parseInt( elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha2.split("/")[2])) && elems.get(2).getText().equals(cantidad2) && elems.get(3).getText().equals(nombreProducto2)) { fail = true; } } assertTrue(dialog != null && fail); }
From source file:ValidSubmission.java
public static void ThenContactInfoIs(String name, String email, String message) { // xpath --> //*[@id='ctl00_MainContent_NameBox'] // String nameForContact = driver.findElement(By.id("ctl00_MainContent_NameBox")).sendKeys(name); // assertEquals(nameForContact, ("Bloggs")); //xpath --> //*[@id='ctl00_MainContent_EmailBox'] // String emailForContact = driver.findElement(By.id("ctl00_MainContent_EmailBox")).sendKeys(email); // assertEquals(emailForContact, ("j.Bloggs@qaworks.com")); //xpath --> //*[@id='ctl00_MainContent_MessageBox'] // String messageForContact = driver.findElement(By.id("ctl00_MainContent_MessageBox")).sendKeys(message); // assertEquals(messageForContact, ("Please contact me I want to find out more")); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); //xpath --> //*[@id='ctl00_MainContent_SendButton'] // driver.findElement(By.id("ctl00_MainContent_SendButton")).click(); driver.findElement(By.xpath("//*[@id='ctl00_MainContent_SendButton']")).submit(); }
From source file:ValidSubmission.java
public static void ThenJobsTitle_ShortDesc_FullDescIs() { // int j =0;/*from w w w .jav a 2s. c o m*/ // Grab the table WebElement table = driver.findElement(By.id("jobListings")); //Get number of rows in table int numOfRow = table.findElements(By.tagName("tr")).size(); List<String> jobLinkUrl = new ArrayList(numOfRow); for (int j = 1; j <= (numOfRow - 2); j = (j + 2)) { String first_part_jobShortDesc_xpath = "//*[@id='jobListings']/tbody/tr["; String second_part_jobShortDesc_xpath = "]/td/span"; String first_part_jobLinkTitle_xpath = "//*[@id='jobListings']/tbody/tr["; String second_part_jobLinkTitle_xpath = "]/td/a"; String first_part_jobLinkUrl_xpath = "//*[@id='jobListings']/tbody/tr["; String second_part_jobLinkUrl_xpath = "]/td/a"; WebElement webJobLinkUrl = driver .findElement(By.xpath(first_part_jobLinkUrl_xpath + (j + 2) + second_part_jobLinkUrl_xpath)); jobLinkUrl.add(webJobLinkUrl.getAttribute("href")); // String final_jobLinkTitle_xpath = first_part_jobLinkTitle_xpath + (j + 2) + second_part_jobLinkTitle_xpath; String final_jobShortDesc_xpath = first_part_jobShortDesc_xpath + (j + 3) + second_part_jobShortDesc_xpath; WebElement webJobLinkTitle = driver.findElement(By.xpath(final_jobLinkTitle_xpath)); String jobLinkTitle = webJobLinkTitle.getText(); WebElement webJobShortDesc = driver.findElement(By.xpath(final_jobShortDesc_xpath)); String jobShortDesc = webJobShortDesc.getAttribute("innerHTML"); System.out.println("Job Title = " + jobLinkTitle); System.out.println(); System.out.println("Short Description of Job = " + jobShortDesc); System.out.println(); System.out.println("Link URL of Job" + jobLinkUrl); System.out.println(); } // // GoTo 'Full Job Description' for (int i = 0; i < jobLinkUrl.size(); i++) { driver.navigate().to(jobLinkUrl.get(i)); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // WebElement webJobFullDescData = driver .findElement(By.xpath("//*[@id='jobDetails']/div[2]/table/tbody/tr[1]/td")); String jobFullDescData = webJobFullDescData.getText(); // System.out.println("Job Full Description Data" + jobFullDescData); System.out.println(); } }
From source file:DesktopChosenIT.java
License:Apache License
/** * Goal: verify that tab navigation is possible when Chosen is within a form. *///ww w . j av a 2 s . co m @Test public void tabNavigation() { // Given loadTestCase(new TabNavigation()); // When webDriverWait().until(elementToBeClickable(By.id("firstTextBox"))); webDriver.switchTo().activeElement().sendKeys(Keys.TAB); webDriver.switchTo().activeElement().sendKeys(Keys.TAB); // at this point, focus is on the Chosen widget final String searchText = "ferr"; webDriver.switchTo().activeElement().sendKeys(searchText); final WebElement inputBox = getInput(); // Then webDriverWait().until(new Predicate<WebDriver>() { @Override public boolean apply(@Nullable WebDriver input) { String value = inputBox.getAttribute("value"); return value != null && value.equals(searchText); } }); }
From source file:ParametrizedSearchTest.java
@Test public void test() throws InterruptedException { driver.get(baseUrl + "/samplecenter/faces/index.xhtml"); driver.findElement(By.id("j_idt11:searchbar")).clear(); Thread.sleep(1000);//from w ww. j av a2 s.c o m driver.findElement(By.id("j_idt11:searchbar")).sendKeys(pattern); Thread.sleep(1000); driver.findElement(By.name("j_idt11:j_idt12")).click(); Thread.sleep(1000); // ne fonctionne pas avec test paramtrs //assertEquals(result, driver.findElement(By.id("resultcount")).getText()); System.out.println("search pattern: " + pattern + ", result: " + result); if (result.equals(driver.findElement(By.id("resultcount")).getText())) { System.out.println("Test passed"); } else { System.err.println("!!! Test failed !!!"); } }