List of usage examples for org.openqa.selenium By name
public static By name(String name)
From source file:com.java.AppTestType_18_11_2015.java
public void EQITQUESFWDTOSELLER(WebDriver driver, String fieldText) { try {//from w ww .j a v a2s . com String field = fieldText; NAVIGATETOLISTINGDETAILSPAGE(driver); getvalue = driver.findElement(By.xpath("//*[@id='ONengine']/div[7]/span")).getText(); System.out.println(getvalue); // SUMAN driver.findElement(By.xpath("//input[@type='button' and @value='Ask it Now']")).click(); Thread.sleep(2000); driver.findElement(By.id("listingQuestion")).click(); String question = "Could you forward my question to SELLER?"; driver.findElement(By.id("listingQuestion")).sendKeys(question); Thread.sleep(1000); driver.findElement(By.name("submitq")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//input[@value='OK'])[2]")).click(); Thread.sleep(4000); /* driver.findElement(By.id("uname")).click(); Thread.sleep(10000); driver.findElement(By.linkText("Sign Out")).click();*/ SIGNOUT(driver); driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(fieldText); driver.manage().deleteAllCookies(); driver.findElement(By.id("aurid")).sendKeys("mglaz@assetnation.com"); driver.findElement(By.id("apwd")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//input[@value='Login']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.id("userAgreementBtn")).click(); Thread.sleep(2000); System.out.println("Searching for lot id : " + getvalue); driver.findElement(By.name("search_string")).clear(); driver.findElement(By.name("search_string")).sendKeys(getvalue); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.xpath("//button")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("Lot Q/A")).click(); WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Forward"))); String ParentHandle = driver.getWindowHandle(); driver.findElement(By.linkText("Forward")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; for (String winHandle : driver.getWindowHandles()) { System.out.println("Entered For Loop"); driver.switchTo().window(winHandle); } Thread.sleep(10000); driver.findElement(By.xpath("//*[contains(@onclick,'FORWARDED TO SELLER')]")).click(); driver.findElement(By.id("id_button_forward")).click(); driver.findElement(By.id("id_frm_textarea_reply")).sendKeys("change in question forward to seller"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.id("id_button_forward_seller_location")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().alert().accept(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().window(ParentHandle); resultDetails.setFlag(true); } catch (StaleElementReferenceException e) { if (retries < MAX_STALE_ELEMENT_RETRIES) { retries++; } else { throw e; } } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("seller is not displayed for this listing"); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void FORWARDTOSTORAGE(WebDriver driver, String fieldText) { try {/*from w ww .ja v a2 s . c o m*/ NAVIGATETOLISTINGDETAILSPAGE(driver); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); getvalue = driver.findElement(By.xpath("//*[@id='ONengine']/div[7]/span")).getText(); System.out.println(getvalue); // SUMAN driver.findElement(By.xpath("//input[@type='button' and @value='Ask it Now']")).click(); Thread.sleep(2000); driver.findElement(By.id("listingQuestion")).click(); String question = "Could you forward my question to Storage Location?"; driver.findElement(By.id("listingQuestion")).sendKeys(question); Thread.sleep(1000); driver.findElement(By.name("submitq")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//input[@value='OK'])[2]")).click(); Thread.sleep(4000); /* driver.findElement(By.id("uname")).click(); Thread.sleep(10000); driver.findElement(By.linkText("Sign Out")).click();*/ SIGNOUT(driver); driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(fieldText); driver.manage().deleteAllCookies(); driver.findElement(By.id("aurid")).sendKeys("mglaz@assetnation.com"); driver.findElement(By.id("apwd")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//input[@value='Login']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.id("userAgreementBtn")).click(); Thread.sleep(2000); System.out.println("Searching for lot id : " + getvalue); driver.findElement(By.name("search_string")).clear(); driver.findElement(By.name("search_string")).sendKeys(getvalue); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.xpath("//button")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("Lot Q/A")).click(); WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Forward"))); String ParentHandle = driver.getWindowHandle(); driver.findElement(By.linkText("Forward")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; for (String winHandle : driver.getWindowHandles()) { System.out.println("Entered For Loop"); driver.switchTo().window(winHandle); } Thread.sleep(5000); driver.findElement(By.xpath("//*[contains(@onclick,'FORWARDED TO LOCATION')]")).click(); driver.findElement(By.id("id_button_forward")).click(); driver.findElement(By.id("id_button_forward_seller_location")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().alert().accept(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().window(ParentHandle); resultDetails.setFlag(true); } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("Storage location is not displayed for this listing"); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void FORWARDTOPM(WebDriver driver, String fieldText) { try {//w ww. ja va2s . c om NAVIGATETOLISTINGDETAILSPAGE(driver); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); getvalue = driver.findElement(By.xpath("//*[@id='ONengine']/div[7]/span")).getText(); System.out.println(getvalue); // SUMAN driver.findElement(By.xpath("//input[@type='button' and @value='Ask it Now']")).click(); Thread.sleep(2000); driver.findElement(By.id("listingQuestion")).click(); String question = "Could you forward my question to SELLER?"; driver.findElement(By.id("listingQuestion")).sendKeys(question); Thread.sleep(1000); driver.findElement(By.name("submitq")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//input[@value='OK'])[2]")).click(); Thread.sleep(4000); /* driver.findElement(By.id("uname")).click(); Thread.sleep(10000); driver.findElement(By.linkText("Sign Out")).click();*/ SIGNOUT(driver); driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(fieldText); driver.manage().deleteAllCookies(); driver.findElement(By.id("aurid")).sendKeys("mglaz@assetnation.com"); driver.findElement(By.id("apwd")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//input[@value='Login']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.id("userAgreementBtn")).click(); Thread.sleep(2000); System.out.println("Searching for lot id : " + getvalue); driver.findElement(By.name("search_string")).clear(); driver.findElement(By.name("search_string")).sendKeys(getvalue); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.xpath("//button")).click(); driver.findElement(By.linkText("Lot Q/A")).click(); WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Forward"))); String ParentHandle = driver.getWindowHandle(); driver.findElement(By.linkText("Forward")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; for (String winHandle : driver.getWindowHandles()) { System.out.println("Entered For Loop"); driver.switchTo().window(winHandle); } Thread.sleep(5000); driver.findElement(By.xpath("//*[contains(@onclick,'FORWARDED TO PM')]")).click(); driver.findElement(By.id("id_button_forward")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().alert().accept(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().window(ParentHandle); resultDetails.setFlag(true); } catch (StaleElementReferenceException e) { if (retries < MAX_STALE_ELEMENT_RETRIES) { retries++; } else { throw e; } } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("PM is not displayed for this listing"); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void ASKQUESTION(WebDriver driver, String fieldText, String value) { try {//w ww . j a va 2 s. c o m int i; List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']")); for (i = 0; i < listings.size(); i++) { WebElement requiredlisting = listings.get(i); requiredlisting.click(); getvalue = driver.findElement(By.xpath("//div[7]/span")).getText(); System.out.println(getvalue); driver.findElement(By.xpath("//div[3]/div[2]/input")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.id("listingQuestion")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.id("listingQuestion")).sendKeys("where is the listing located"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.name("submitq")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.xpath("//div/div[2]/div[3]/input")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.cssSelector("span")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.linkText("Sign Out")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(fieldText); driver.manage().deleteAllCookies(); driver.findElement(By.id("aurid")).sendKeys("mglaz@assetnation.com"); driver.findElement(By.id("apwd")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//input[@value='Login']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.id("userAgreementBtn")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); System.out.println(getvalue); driver.findElement(By.id("quicksearch")).sendKeys(getvalue); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.cssSelector("input.quicksearch_go")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.linkText("Lot Q/A")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; String ParentHandle = driver.getWindowHandle(); driver.findElement(By.linkText("Forward")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; for (String winHandle : driver.getWindowHandles()) { System.out.println("Entered For Loop"); driver.switchTo().window(winHandle); } driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.xpath("//td/input[4]")).click(); driver.findElement(By.id("id_button_forward")).click(); driver.findElement(By.id("id_button_forward_seller_location")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().alert().accept(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.switchTo().window(ParentHandle); driver.findElement(By.xpath("//ul/ul/li/a")).click(); driver.findElement(By.xpath("//td[2]/a")).click(); String seller = driver.findElement(By.id("id_frm_Email_Address")).getAttribute("value"); driver.findElement(By.linkText("Logout")).click(); driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(value); driver.findElement(By.id("sign")).click(); driver.findElement(By.id("loginfield")).sendKeys(seller); driver.findElement(By.id("pwdfield")).sendKeys("Equipment1$"); driver.findElement(By.cssSelector("input.secondary_110")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; driver.findElement(By.linkText("MYONE")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); resultDetails.setFlag(true); } } catch (Exception e) { resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void DRAFTLISTING(WebDriver driver, String fieldText) { String fieldType = fieldText; String field = fieldText;//from w ww .j a v a 2 s .com try { AppKeyWords cdf = AppKeyWords.valueOf(fieldType.toUpperCase()); switch (cdf) { case EA: try { driver.findElement(By.cssSelector("a.topLink > span")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Equipment & Accessories']")).click(); driver.findElement(By.id("chkCustomBuilt")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); Select industry = new Select(driver.findElement(By.id("select_industry"))); industry.selectByVisibleText("Vehicles & Buses"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); Select category = new Select(driver.findElement(By.id("select_category"))); category.selectByVisibleText("Cars"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); Select subcategory = new Select(driver.findElement(By.id("select_subcategory"))); subcategory.selectByVisibleText("Car"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.findElement(By.name("6")).sendKeys("SKODA"); driver.findElement(By.name("3")).sendKeys("SK4"); driver.findElement(By.name("2")).sendKeys("2014"); driver.findElement(By.name("4")).sendKeys("125"); driver.findElement(By.id("confirm_changes")).click(); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.id("title")).sendKeys(" " + Time); String title = driver.findElement(By.id("title")).getText(); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); Thread.sleep(10000); driver.findElement(By.linkText("MYONE")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//div[3]/div/div/div/div/div/div/div/ul/li[3]/ul/li/a")).click(); Thread.sleep(10000); driver.findElement(By.xpath("//div[15]/ul/li/a")).click(); Thread.sleep(10000); if (driver.getPageSource().contains(title)) { resultDetails.setFlag(true); System.out.println("listing is displayed"); } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); resultDetails.setErrorMessage("Listing is not displayed in Drafts tab"); } break; case COMMERCIAL: try { driver.findElement(By.cssSelector("a.topLink > span")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Commercial Materials']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.id("textarea")).sendKeys("Test"); driver.findElement(By.id("confirm_changes")).click(); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.id("title")).sendKeys(" " + Time); String title = driver.findElement(By.id("title")).getText(); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); Thread.sleep(10000); driver.findElement(By.linkText("MYONE")).click(); Thread.sleep(10000); driver.findElement(By.xpath("//div[3]/div/div/div/div/div/div/div/ul/li[3]/ul/li/a")).click(); Thread.sleep(10000); driver.findElement(By.xpath("//div[15]/ul/li/a")).click(); Thread.sleep(10000); if (driver.getPageSource().contains(title)) { resultDetails.setFlag(true); System.out.println("listing is displayed"); } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); resultDetails.setErrorMessage("Listing is not displayed in Drafts tab"); } break; } } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("EA or Commercial listings are not displayed"); } }
From source file:com.java.AppTestType_18_11_2015.java
public void NEWUSERREGISTRATION(WebDriver driver, String fieldText, String value) { //NEW user registration //Registration URL in FieldText field //AMP URL in value field try {/*from w w w.j a va 2 s. co m*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); String value1 = "Val"; LITEUSERREGISTRATION(driver, fieldText, value1); driver.manage().deleteAllCookies(); driver.navigate().refresh(); driver.get(value); AMPLOGIN(driver, value); driver.findElement(By.linkText("Users")).click(); driver.findElement(By.name("email")).sendKeys(EMAIL); driver.findElement(By.xpath("//input[@value='Search']")).click(); String VerifyUser = driver.findElement(By.xpath("//input[@value='Search']/following::tr[3]/td[2]")) .getText(); if (VerifyUser.equalsIgnoreCase(EMAIL)) ; { System.out.println("User Verified"); } resultDetails.setFlag(true); } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setWarningMessage("Registration failed"); } }
From source file:com.java.AppTestType_18_11_2015.java
public void SIGNIN(WebDriver driver, String fieldText, String value) { try {// ww w. j av a 2s. c o m try { WebDriverWait wait = new WebDriverWait(driver, 20); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.manage().deleteAllCookies(); //driver.findElement(By.linkText("Sign In")).click(); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); try { driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); } catch (Exception elementnotfoundexException) { driver.findElement(By.xpath("//button[text()='SIGN IN']")).click(); } System.out.println("size is :" + driver.findElements(By.id("iduser")).size()); if (driver.findElements(By.id("iduser")).size() > 0) { System.out.println("1111111111"); driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement( By.xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } //to confirm successful sign in as valid user,verifying the name displayed next to "Hello" text if (driver.findElement(By.id("iduser")).getText().equalsIgnoreCase(value)) System.out.println("Successfully Logged in"); else { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("Sign Out")).click(); wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name("josso_password"))); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); wait.until(ExpectedConditions.elementToBeClickable(By.id("iduser"))); //agree terms-This piece of code is to verify agree terms checkbox after re logging(not logged in as the valid user) driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement(By .xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } } resultDetails.setFlag(true); } } //This catch is used to catch the error "You are NOT authorized to access Site" in E1 Login// ///////////////////////////////////// catch (Exception e1) { driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.getPageSource().contains("You are NOT authorized to access Site")) { System.out.println("You are NOT authorized to access Site error message is displayed"); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com"); SIGNIN(driver, fieldText, value); } } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void APPROVEUSER(WebDriver driver, String fieldText, String value) { //To Handle Approve User Popup //FieldText---The User's FullName and Value-----OK or Cancel try {//from w w w . j av a 2 s.c o m driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText(fieldText)).click(); Thread.sleep(2000); String parentwindow = driver.getWindowHandle(); if (value.equalsIgnoreCase("OK")) { driver.findElement(By.linkText("Approve User")).click(); Thread.sleep(2000); driver.switchTo().alert().accept(); for (String win : driver.getWindowHandles()) { driver.switchTo().window(win); try { driver.switchTo().alert().accept(); } catch (NoAlertPresentException e) { Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_SPACE); Thread.sleep(3000); } } Thread.sleep(20000); driver.switchTo().window(parentwindow); WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id_frm_Email_Address"))); String Email = driver.findElement(By.id("id_frm_Email_Address")).getText(); driver.findElement(By.name("email")).sendKeys(EMAIL); driver.findElement(By.xpath("//input[@value='Search']")).click(); String Type = driver.findElement(By.xpath("//input[@value='Search']/following::tr[3]/td[6]")) .getText(); String Active_Status = driver .findElement(By.xpath("//input[@value='Search']/following::tr[3]/td[6]")).getText(); String BStatus = driver.findElement(By.xpath("//input[@value='Search']/following::tr[3]/td[6]")) .getText(); String SStatus = driver.findElement(By.xpath("//input[@value='Search']/following::tr[3]/td[6]")) .getText(); if (Type.equalsIgnoreCase("L") && Active_Status.equalsIgnoreCase("Active") && BStatus.equalsIgnoreCase("Approved") && SStatus.equalsIgnoreCase("Approved")) { resultDetails.setFlag(true); } } else if (value.equalsIgnoreCase("CANCEL")) { driver.findElement(By.linkText("Approve User")).click(); Thread.sleep(2000); //Robot robot = new Robot(); // Simulate SPACE KEY press to click on OK button //robot.keyPress(KeyEvent.VK_ESCAPE); driver.switchTo().alert().dismiss(); resultDetails.setFlag(true); } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void BIDONOWNLOT(WebDriver driver, String fieldText, String value) { try {/*ww w .j a va2s. com*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); AMPLOGIN(driver, value); driver.findElement(By.linkText("Lots")).click(); Thread.sleep(4000); new Select(driver.findElement(By.xpath("//select[@name='venueID']"))) .selectByVisibleText("EquipmentOne"); new Select(driver.findElement(By.xpath("//select[@name='offerSrhListingStatus']"))) .selectByVisibleText("Approved"); driver.findElement(By.xpath("//input[@name='find_button']")).click(); driver.findElement(By.xpath("//*[@id='renderView']/table[2]/tbody/tr[1]/td[2]/table/tbody/tr[1]/td/a")) .click(); String EQID = driver .findElement(By.xpath("//td[@class='listdatabold' and text()='Lot Number:']/../td[4]")) .getText(); System.out.println("EQID is: " + EQID); driver.findElement(By.xpath("//td[@class='listdatabold' and text()='Seller:']/../td[2]/a")).click(); Thread.sleep(5000); String SellerMailID = driver.findElement(By.id("id_frm_Email_Address")).getAttribute("value"); System.out.println("SellerMailID is: " + SellerMailID); AMPLOGOUT(driver); driver.get(fieldText); WebDriverWait wait = new WebDriverWait(driver, 30); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(SellerMailID); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); Thread.sleep(4000); driver.findElement(By.id("search")).sendKeys(EQID); driver.findElement(By.xpath("//*[@id='main_search']/button")).click(); Thread.sleep(4000); //driver.findElement(By.xpath("(//*[@name='makeoffer'])[2]")).click(); driver.findElement(By.xpath("(//*[@name='makeoffer'])[2]")).sendKeys("99999999999"); driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//input[@class='form-control jsOfferInput e1ConfirmInput'])[2]")) .sendKeys("99999999999"); driver.findElement(By.xpath("(//input[@class='btn btn-primary jsConfirmOffer'])[2]")).click(); Thread.sleep(4000); if (driver.findElement(By.tagName("html")).getText() .contains("You are attempting to place a bid on a lot you own, this is not allowed.")) resultDetails.setFlag(true); } catch (Exception e2) { e2.printStackTrace(); resultDetails.setErrorMessage("something went wrong"); resultDetails.setFlag(false); } }
From source file:com.joyce.automation.util.prop.Prop.java
License:Apache License
/** * /*from w w w. j a v a 2 s.c om*/ * ??:???? * * @param elementNameInProp * ?key(eg:login.username=id>value ) * @author jiaozhongbin * @throws Exception */ public By getLocator(String elementNameInProp) { String locator = properties.getProperty(elementNameInProp); String locatorType = locator.split(Const.DEFAULT_SPLIT)[0]; String locatorValue = locator.split(Const.DEFAULT_SPLIT)[1]; try { // locatorValue = new String(locatorValue.getBytes("ISO-8859-1"), "UTF-8"); if (locatorType.toLowerCase().equals("id")) { return By.id(locatorValue); } else if (locatorType.toLowerCase().equals("xpath")) { return By.xpath(locatorValue); } else if (locatorType.toLowerCase().equals("name")) { return By.name(locatorValue); } else if (locatorType.toLowerCase().equals("classname") || locatorType.toLowerCase().equals("class")) { return By.className(locatorValue); } else if (locatorType.toLowerCase().equals("tagname") || locatorType.toLowerCase().equals("tag")) { return By.tagName(locatorValue); } else if (locatorType.toLowerCase().equals("linktext") || locatorType.toLowerCase().equals("link")) { return By.linkText(locatorValue); } else if (locatorType.toLowerCase().equals("partiallinktext")) { return By.partialLinkText(locatorValue); } else if (locatorType.toLowerCase().equals("cssselector") || locatorType.toLowerCase().equals("css")) { return By.cssSelector(locatorValue); } else log.error("locatorType?:" + locatorType); return null; } catch (IllegalArgumentException e1) { log.error("{" + locatorType + "=" + locatorValue + "}?", e1); } return null; }