List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:com.ibm.sbt.automation.core.test.BaseSampleFrameworkTest.java
License:Open Source License
public boolean checkIframe(SampleFrameworkResultPage resultPage) { WebDriverWait wait = new WebDriverWait(resultPage.getWebDriver(), 20l); WebElement iframeBody = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("body"))); String bodyClass = iframeBody.getAttribute("class"); return bodyClass != null; }
From source file:com.ibm.sbt.automation.core.test.pageobjects.VCardResultPage.java
License:Open Source License
/** * Get the html ul representing the navigation options in the community card. * //from ww w. j ava2 s . com * @return the WebElement */ public WebElement waitForCommunityCardNav() { WebDriverWait wait = new WebDriverWait(getWebDriver(), 5); WebElement result = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("bizCardNav"))); // wait until the community card nav is available. return result; }
From source file:com.ibm.sbt.automation.core.test.pageobjects.VCardResultPage.java
License:Open Source License
/** * This method hovers over the card's attach point and then clicks the hover menu which appears. This should bring up the VCard. * /* w w w .j av a 2 s .c o m*/ * @return True if the ProfileCard appeared, false if not. */ public boolean isProfileCardDisplayable(WebElement cardAttachPoint) { WebDriver driver = getWebDriver(); new Actions(driver).moveToElement(cardAttachPoint).perform(); // hover over the attachpoint to make the semtagmenu appear. WebDriverWait wait = new WebDriverWait(driver, 5); WebElement semtagmenu = wait.until(ExpectedConditions.elementToBeClickable(By.id("semtagmenu"))); // wait until the hover menu is clickable. WebElement semTagHoverMenu = semtagmenu.findElement(By.xpath(".//a")); new Actions(driver).click(semTagHoverMenu).perform(); // click the hovering menu WebElement vCardDiv = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cardDiv"))); return vCardDiv.isDisplayed(); }
From source file:com.ibm.sbt.test.sample.framework.SampleFrameworkJava.java
License:Open Source License
private boolean checkCodeDivs(SampleFrameworkResultPage resultPage) { WebElement jspDiv = resultPage.getJspSnippetDiv(); String jspContent = jspDiv.getAttribute("innerHTML"); WebElement ulNav = resultPage.getCodeNav(); List<WebElement> tabList = ulNav.findElements(By.xpath(".//a")); WebDriverWait wait = new WebDriverWait(resultPage.getWebDriver(), 2); tabList.get(1).click();//from w w w. j ava 2 s .c om boolean docDivDisplayed = wait.until( ExpectedConditions.visibilityOfElementLocated(By.id(SampleFrameworkResultPage.DOCSNIPPETDIV))) .isDisplayed(); return jspContent != null && docDivDisplayed; }
From source file:com.ibm.sbt.test.sample.framework.SampleFrameworkJavaScript.java
License:Open Source License
private boolean checkCodeDivs(SampleFrameworkResultPage resultPage) { WebElement jsDiv = resultPage.getJsSnippetDiv(); String jsContent = jsDiv.getAttribute("innerHTML"); WebElement ulNav = resultPage.getCodeNav(); List<WebElement> tabList = ulNav.findElements(By.xpath(".//a")); WebDriverWait wait = new WebDriverWait(resultPage.getWebDriver(), 5l); tabList.get(1).click();//from w ww . j ava2s . c om boolean htmlDivDisplayed = wait.until( ExpectedConditions.visibilityOfElementLocated(By.id(SampleFrameworkResultPage.HTMLSNIPPETDIV))) .isDisplayed(); tabList.get(2).click(); boolean cssDivDisplayed = wait.until( ExpectedConditions.visibilityOfElementLocated(By.id(SampleFrameworkResultPage.CSSSNIPPETDIV))) .isDisplayed(); tabList.get(3).click(); boolean docDivDisplayed = wait.until( ExpectedConditions.visibilityOfElementLocated(By.id(SampleFrameworkResultPage.DOCSNIPPETDIV))) .isDisplayed(); return jsContent != null && htmlDivDisplayed && cssDivDisplayed && docDivDisplayed; }
From source file:com.java.AppTestType_18_11_2015.java
public void ELISTINGS(WebDriver driver) { //Equipment and Accessories listings creation from selfservice. try {//from ww w .j a v a 2s . c om 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); Listingtitle = driver.findElement(By.id("title")).getAttribute("value"); System.out.println(Listingtitle); 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("reserveAmount")).sendKeys("100"); driver.findElement(By.id("buyItNowPrice")).sendKeys("200"); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//input[@value='Save & Continue']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//input[@value='Save & Submit Listing']"))); driver.findElement(By.xpath("//input[@value='Save & Submit Listing']")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); Calendar currentdate = Calendar.getInstance(); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); TimeZone obj = TimeZone.getTimeZone("CST"); formatter.setTimeZone(obj); System.out.println("Local:: " + currentdate.getTime()); System.out.println("CST:: " + formatter.format(currentdate.getTime())); driver.findElement(By.xpath("//input[@value='Payment Options >']")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.switchTo().alert().accept(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.id("customer_first_name")).sendKeys("aditya"); driver.findElement(By.id("customer_last_name")).sendKeys("charan"); driver.findElement(By.id("cc_number")).sendKeys("4444333322221111"); driver.findElement(By.id("cc_cvv2")).sendKeys("564"); Select month = new Select(driver.findElement(By.id("cc_exp_month"))); month.selectByVisibleText("01 - January"); Select Year = new Select(driver.findElement(By.id("cc_exp_year"))); Year.selectByVisibleText("2021"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//li/div/input[2]")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.cssSelector("a.logo")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//a[@id='iduser']/span")).click(); driver.findElement(By.linkText("Sign Out")).click(); driver.manage().deleteAllCookies(); driver.navigate().refresh(); resultDetails.setFlag(true); } catch (StaleElementReferenceException e) { if (retries < MAX_STALE_ELEMENT_RETRIES) { retries++; } else { throw e; } } catch (Exception e) { resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void LOADNEWUSERREG(WebDriver driver, String fieldText, String value) { try {/*w ww . ja v a 2 s . c om*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.get(fieldText); int num = Integer.parseInt(value); int i; for (i = 0; i <= num; i++) { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.get(fieldText); String pwd = "Equipment1$"; String phone = ""; String Email = ""; String Fname = "Load"; String lname = "Test"; String validation = ""; long inc = Math.round(Math.random() * 100000); // generates 5 digit number. String ID = "@yahoo.in"; Random random = new Random(); long dphone = Math.round(random.nextFloat() * Math.pow(10, 12)); Email = Fname + lname + inc + ID; driver.findElement(By.id("emailaddress")).sendKeys(Email); System.out.println(Email); phone = Long.toString(dphone); driver.findElement(By.id("firstname")).sendKeys(Fname); driver.findElement(By.id("lastname")).sendKeys(lname); driver.findElement(By.id("phone")).sendKeys(phone); driver.findElement(By.id("newPassword")).sendKeys(pwd); driver.findElement(By.id("confirmPassword")).sendKeys(pwd); driver.findElement(By.xpath("//button[text()='JOIN NOW']")).click(); //condition to check the email is already exist if (driver.findElements(By.xpath("//*[@class='error-txt']")).size() > 0) { //If the email" Email Address already exists" if (driver.findElement(By.xpath("//*[@class='error-txt']")).getText() .contains("Email Address already exists in the system")) { inc = inc++; Email = Fname + lname + inc + "test" + ID; driver.findElement(By.id("emailaddress")).clear(); driver.findElement(By.id("emailaddress")).sendKeys(Email); driver.findElement(By.xpath("//button[text()='JOIN NOW']")).click(); } // If the phone number already exist if (driver.findElement(By.xpath("//*[@class='error-txt']")).getText() .contains("Another user has the same daytime phone number")) { phone = phone + random.nextInt(9); driver.findElement(By.id("phone")).clear(); driver.findElement(By.id("phone")).sendKeys(phone); driver.findElement(By.xpath("//button[text()='JOIN NOW']")).click(); } } //Verifying that user is successfully registered WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//*[@class='fa fa-user famember-icon']"))); //verifying the "Activate your membership" icon System.out.println("Successfully Registered"); System.out.println(Email); } resultDetails.setFlag(true); } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void FACETS(WebDriver driver, String fieldText, String value) { String fieldType = fieldText; String field = fieldText;// ww w . j a v a2 s. co m try { AppKeyWords FCT = AppKeyWords.valueOf(fieldType.toUpperCase()); ALLEQUIPMENTPAGE(driver); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); switch (FCT) { case MAKE: try { // suman // driver.findElement(By.linkText("ALL EQUIPMENT")).click(); Thread.sleep(2000); driver.findElement(By.linkText("Make")).click(); Thread.sleep(2000); driver.findElement(By.xpath("(//*[@id='Make']/ul/li[1]/span/input)[2]")).click(); Thread.sleep(1000); String Makecount = driver.findElement(By.xpath("(//*[@id='Make']/ul/li[1])[2]")).getText(); System.out.println(Makecount); String RBMakecount = Makecount.substring(Makecount.indexOf("(") + 1, Makecount.lastIndexOf(")")); Integer totalCount = Integer.parseInt(RBMakecount); System.out.println("Expected count: " + totalCount); boolean result = FACETS_COMPARISON(driver, totalCount); if (result) { resultDetails.setFlag(true); } else System.out.println("count mis-matched"); } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } break; case CATEGORY: try { driver.findElement(By.xpath("//li/input")).click(); String Categorycount = driver.findElement(By.xpath("//div[10]/div/div/ul/li/a")).getText(); String RBCategorycount = Categorycount.substring(Categorycount.indexOf("(") + 1, Categorycount.lastIndexOf(")")); System.out.println(RBCategorycount); String categoryfinal = driver.findElement(By.id("e1NumFound")).getText(); if (RBCategorycount.equalsIgnoreCase(categoryfinal)) { resultDetails.setFlag(true); System.out.println("Counts matched!!!"); } } catch (Exception e) { resultDetails.setFlag(false); } break; case MODEL: try { driver.findElement(By.linkText("Model")).click(); Thread.sleep(2000); driver.findElement(By.xpath("(//*[@id='Model']/ul/li[1]/span/input)[2]")).click(); Thread.sleep(1000); String Makecount = driver.findElement(By.xpath("(//*[@id='Model']/ul/li[1])[2]")).getText(); System.out.println(Makecount); String RBMakecount = Makecount.substring(Makecount.indexOf("(") + 1, Makecount.lastIndexOf(")")); Integer totalCount = Integer.parseInt(RBMakecount); System.out.println("Expected count: " + totalCount); Thread.sleep(3000); boolean result = FACETS_COMPARISON(driver, totalCount); if (result) { resultDetails.setFlag(true); } else System.out.println("count mis-matched"); } catch (Exception e) { resultDetails.setFlag(false); } break; case COUNTRY: try { Thread.sleep(2000); driver.findElement(By.linkText("Country")).click(); Thread.sleep(2000); driver.findElement(By.xpath("(//*[@id='Country']/ul/li[1]/span/input)[2]")).click(); Thread.sleep(1000); String Makecount = driver.findElement(By.xpath("(//*[@id='Country']/ul/li[1])[2]")).getText(); System.out.println(Makecount); String RBMakecount = Makecount.substring(Makecount.indexOf("(") + 1, Makecount.lastIndexOf(")")); Integer totalCount = Integer.parseInt(RBMakecount); System.out.println("Expected count: " + totalCount); Thread.sleep(3000); boolean result = FACETS_COMPARISON(driver, totalCount); if (result) { resultDetails.setFlag(true); } else System.out.println("count mis-matched"); } catch (Exception e) { System.out.println("entered in catch block " + e); resultDetails.setFlag(false); } break; case STATE: try { driver.findElement(By.linkText("State/Province")).click(); Thread.sleep(2000); driver.findElement(By.xpath("(//*[@id='State/Province']/ul/li[1]/span/input)[2]")).click(); Thread.sleep(1000); String Makecount = driver.findElement(By.xpath("(//*[@id='State/Province']/ul/li[1])[2]")) .getText(); System.out.println(Makecount); String RBMakecount = Makecount.substring(Makecount.indexOf("(") + 1, Makecount.lastIndexOf(")")); Integer totalCount = Integer.parseInt(RBMakecount); System.out.println("Expected count: " + totalCount); Thread.sleep(3000); boolean result = FACETS_COMPARISON(driver, totalCount); if (result) { resultDetails.setFlag(true); } else System.out.println("count mis-matched"); } catch (Exception e) { resultDetails.setErrorMessage("The count don't match!"); resultDetails.setFlag(false); } break; case SOURCESITE: try { Thread.sleep(3000); String msg = driver.findElement(By.id("e1SitesFound")).getText(); driver.findElement(By.linkText("Source Site")).click(); Thread.sleep(2500); if (msg.contains("Ritchie Bros")) driver.findElement(By.xpath("(//*[@id='site_id:RBA']/span[1]/input)[2]")).click(); Thread.sleep(3000); if (msg.contains("SalvageSale")) driver.findElement(By.xpath("(//*[@id='site_id:SS']/span[1]/input)[2]")).click(); Thread.sleep(3000); //String E1Count = driver.findElement(By.cssSelector("span.e1Count")).getText();// System.out.println("size1 issssssssssssssssssss: " + driver.findElements(By.xpath("(//*[@id='site_id:E1']/span[3])[2]")).size()); String E1Count = driver.findElement(By.xpath("(//*[@id='site_id:E1']/span[3])[2]")).getText(); System.out.println(E1Count); String EOCountt = E1Count.substring(E1Count.indexOf("(") + 1, E1Count.lastIndexOf(")")); Integer count1 = Integer.parseInt(EOCountt); System.out.println("count1 is: " + count1); Integer totalCount = count1; //suman Thread.sleep(5000); System.out.println( "size2 isssssssssssssssssssssss" + driver.findElements(By.id("e1NumFound")).size()); System.out.println( "size3 isssssssssssssssssssssss" + driver.findElements(By.id("e1ResultsFound")).size()); String listingcount = driver.findElement(By.id("e1NumFound")).getText(); String eventcount = driver.findElement(By.id("e1ResultsFound")).getText(); System.out.println(listingcount); System.out.println(eventcount); boolean lotDisplay = driver.findElement(By.id("e1NumFound")).isDisplayed();//To verify lot count if displayed or not boolean eventDisplay = driver.findElement(By.id("e1ResultsFound")).isDisplayed(); String listingcount2 = ""; int convlistingcount = 0; if (lotDisplay) { listingcount2 = listingcount.replace(",", ""); convlistingcount = Integer.parseInt(listingcount2); } String eventcount2 = ""; int conveventcount = 0; if (eventDisplay) { eventcount2 = eventcount.replace(",", ""); conveventcount = Integer.parseInt(eventcount2); } System.out.println("lot count is: " + convlistingcount); System.out.println("event count is: " + conveventcount); int myfinalcount = convlistingcount + conveventcount; String compfinalcount = String.valueOf(myfinalcount); System.out.println(totalCount); System.out.println(myfinalcount); if (myfinalcount == totalCount) { resultDetails.setFlag(true); System.out.println("Counts matched!"); } else resultDetails.setFlag(false); } catch (Exception e) { resultDetails.setFlag(false); } break; case POSTALCODE: try { WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//*[@id='Zip']/a)[2]"))); driver.findElement(By.xpath("(//*[@id='Zip']/a)[2]")).click(); Thread.sleep(1000); driver.findElement(By.xpath("(//button[contains(@class,'zip_search')])[2]")).click(); Thread.sleep(1000); if (driver.findElement(By.xpath("//*[@class='zip_code']/../div/ul/li")).getText() .equalsIgnoreCase("Required Field.")) { resultDetails.setFlag(true); } } catch (Exception e) { resultDetails.setFlag(false); } break; } } catch (Exception e) { resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void MAXOFFERINDETAILSPAGE(WebDriver driver) { try {//from w w w.j a v a2 s . co m driver.findElement(By.linkText("ALL EQUIPMENT")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; // Loops through the listings in search results page and clicks the first listing available on the page. List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']")); Random r = new Random(); int randomValue = r.nextInt(listings.size()); //Getting a random value that is between 0 and (list's size)-1 listings.get(randomValue).click(); Thread.sleep(10000); String offer = driver.findElement(By.xpath("//span/div[2]/div/span")).getText(); System.out.println(offer); String Max = offer.substring(1, offer.length() - 2); if (Max.indexOf(',') > -1) { System.out.println("Field has comma"); String convert = Max.replace(",", ""); String dot = convert.replace(".", ""); int mymaxoffer = Integer.parseInt(dot); int finaladding = add + mymaxoffer; String convadd = String.valueOf(finaladding); System.out.println(convadd); ListingsID = driver.findElement(By.xpath("//div[7]/span")).getText(); System.out.println(ListingsID); driver.findElement(By.cssSelector("input.jsOfferInput")).sendKeys(convadd); WebDriverWait wait = new WebDriverWait(driver, 40000); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[3]/button"))); driver.findElement(By.xpath("//div[3]/button")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement(By.cssSelector("input.jsOfferInput.e1ConfirmInput")).sendKeys(convadd); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[5]/div[3]/button"))); driver.findElement(By.xpath("//div[5]/div[3]/button")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); boolean isPresent = driver.findElement(By.cssSelector("input.jsTermsAgree")).isDisplayed(); if (isPresent == true) { driver.findElement(By.cssSelector("input.jsTermsAgree")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } else { driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } } else { System.out.println("field does not have comma"); String mydot = Max.replace(".", ""); System.out.println(mydot); int getmaxoffer = Integer.parseInt(mydot); int addingfinal = add + getmaxoffer; String myconvadd = String.valueOf(addingfinal); driver.findElement(By.xpath("//div[3]/input")).sendKeys(myconvadd); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[3]/button"))); driver.findElement(By.xpath("//div[3]/button")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement(By.xpath("//div[5]/div[3]/input")).sendKeys(myconvadd); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[5]/div[3]/button"))); driver.findElement(By.xpath("//div[5]/div[3]/button")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); boolean isPresent = driver.findElement(By.cssSelector("input.jsTermsAgree")).isDisplayed(); if (isPresent == true) { driver.findElement(By.cssSelector("input.jsTermsAgree")).click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } else { Thread.sleep(10000); driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } } resultDetails.setFlag(true); } catch (StaleElementReferenceException e) { if (retries < MAX_STALE_ELEMENT_RETRIES) { retries++; } else { throw e; } } catch (Exception e) { resultDetails.setFlag(false); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void EXACTOFFERINDETAILSPAGE(WebDriver driver) { try {/* w w w. j a v a 2 s . co m*/ driver.findElement(By.linkText("ALL EQUIPMENT")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ; // Loops through the listings in search results page and clicks the first listing available on the page. // suman List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']")); Random r = new Random(); int randomValue = r.nextInt(listings.size()); //Getting a random value that is between 0 and (list's size)-1 listings.get(randomValue).click(); Thread.sleep(10000); String offer = driver.findElement(By.xpath("//span/div[2]/div/span")).getText(); System.out.println(offer); String Max = offer.substring(1, offer.length() - 2); ListingsID = driver.findElement(By.xpath("//div[7]/span")).getText(); if (Max.indexOf(',') > -1) { System.out.println("Field has comma"); String convert = Max.replace(",", ""); String dot = convert.replace(".", ""); System.out.println(dot); int mymaxoffer = Integer.parseInt(dot); int finaladding = add + mymaxoffer; String convadd = String.valueOf(finaladding); driver.findElement(By.xpath("//span[2]/input")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//div[3]/input")).sendKeys(convadd); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[3]/input"))); driver.findElement(By.xpath("//div[3]/button")).click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.xpath("//div[5]/div[3]/input")).sendKeys(convadd); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[5]/div[3]/input"))); driver.findElement( By.cssSelector("div.e1ConfirmButton button.e1Buttons.jsConfirmOffer.e1OrangeShadow")) .click(); Thread.sleep(20000); boolean isPresent = driver.findElement(By.cssSelector("input.jsTermsAgree")).isDisplayed(); if (isPresent == true) { driver.findElement(By.cssSelector("input.jsTermsAgree")).click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[9]/button"))); driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } else { driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } } else { System.out.println("field does not have comma"); String mydot = Max.replace(".", ""); System.out.println(mydot); int mymaxoffer = Integer.parseInt(mydot); int finaladding = add + mymaxoffer; String convadd = String.valueOf(finaladding); driver.findElement(By.xpath("//span[2]/input")).click(); Thread.sleep(10000); driver.findElement(By.xpath("//div[3]/input")).sendKeys(convadd); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[3]/input"))); driver.findElement( By.cssSelector("div.e1OfferButton.jsOfferLive button.e1Buttons.e1OrangeShadow.jsMakeOffer")) .click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement(By.xpath("//div[5]/div[3]/input")).sendKeys(convadd); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[5]/div[3]/input"))); driver.findElement( By.cssSelector("div.e1ConfirmButton button.e1Buttons.jsConfirmOffer.e1OrangeShadow")) .click(); Thread.sleep(20000); boolean isPresent = driver.findElement(By.cssSelector("input.jsTermsAgree")).isDisplayed(); if (isPresent == true) { driver.findElement(By.cssSelector("input.jsTermsAgree")).click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[9]/button"))); driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } else { driver.findElement(By.xpath("//li[9]/button")).click(); Thread.sleep(10000); } } resultDetails.setFlag(true); } catch (StaleElementReferenceException e) { if (retries < MAX_STALE_ELEMENT_RETRIES) { retries++; } else { throw e; } } catch (Exception e) { resultDetails.setFlag(false); } }