List of usage examples for org.openqa.selenium WebDriver manage
Options manage();
From source file:com.java.AppTestType_18_11_2015.java
public void FORWARDTOSTORAGE(WebDriver driver, String fieldText) { try {/*from w w w . j av a2 s . 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 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 {/*from www . j a va 2s . co 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 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 MAXOFFERINDETAILSPAGE(WebDriver driver) { try {// ww 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 {/*from ww 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); } }
From source file:com.java.AppTestType_18_11_2015.java
public void MAXOFFERINSEARCHRESULTSPAGE(WebDriver driver) { try {// w w w .j av a2s . co m driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings"); Thread.sleep(1000); driver.findElement(By.linkText("2")).click();//To go to 2nd page of the search results Thread.sleep(10000); //in search result there may be events, so finding first listing(excluding events) to offer exact bid List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']")); int j = -1; for (int i = 1; i < listings.size(); i++) { j++; String s1 = listings.get(i).getAttribute("href"); String s2[] = s1.split("/listing?"); String s3[] = s2[1].split("&"); String s4[] = s3[0].split("="); String id = s4[1]; System.out.println("listing id is: " + id); System.out.println("listing-" + id); String listingText = driver.findElement(By.id("listing-" + id)).getText(); //String Text[]=listingText.split("\n"); System.out.println("text in listing is:................... " + listingText); if (listingText.contains("MAX BID")) { break; } i++; } System.out.println("number of listings in page: " + listings.size()); //taking first listing (not concidering events) WebElement we = listings.get(j); String href = we.getAttribute("href"); System.out.println("href of first listing is: " + href); // (//a[@href='http://e1.dev.assetnation.com/listing?listingid=316696&backToSearchButton=1']/following::*[@class='jsMinOfferjsAmountText'])[1] if (href.contains("http://e1.dev.assetnation.com")) href = href.replaceAll("http://e1.dev.assetnation.com", ""); else if (href.contains("http://e1.dev.assetnation.com/")) href = href.replaceAll("http://e1.dev.assetnation.com/", ""); String min_offer = driver .findElement(By .xpath("(//a[@href='" + href + "']/following::*[@class='jsMinOffer jsAmountText'])[1]")) .getText(); String min_offer2 = min_offer.substring(1, min_offer.length() - 3); String min_offer3 = min_offer2.replace(",", ""); Integer minOffer = Integer.parseInt(min_offer3); System.out.println("minimum offer is: " + minOffer); Integer bidAmount = add + minOffer; String bidValue = String.valueOf(bidAmount); //clicking on Place a Bid button driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='text' and @name='makeoffer'])[1]")) .clear(); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='text' and @name='makeoffer'])[1]")) .sendKeys(bidValue); driver.findElement(By .xpath("(//a[@href='" + href + "']/following::*[@type='button' and @value='PLACE A BID'])[1]")) .click(); Thread.sleep(2000); driver.findElement(By.xpath("(//a[@href='" + href + "']/following::*[@class='form-control jsOfferInput e1ConfirmInput' and@type='text'])[1]")) .sendKeys(bidValue); // String ss=driver.findElement(By.xpath("(//a[@href='"+href+"']/following::*[@class='form-control jsOfferInput'])[1]")).getText(); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='button' and @value='CONTINUE'])[1]")) .click(); Thread.sleep(2000); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); //some times we have confirmation check-box and some times we dont have try { driver.findElement(By.xpath("(//input[@class='jsTermsAgree' and @type='checkbox'])[2]")).click(); } catch (Exception e) { System.out.println("there is no confirm check box"); } driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='submit' and @value='Submit'])[1]")) .click(); Thread.sleep(2000); for (int i = 0; i < 20; i++) { if (driver .findElement( By.xpath("(//a[@href='" + href + "']/following::*[@class='jsMyMaxBidValue'])[1]")) .getText().contains("$")) break; Thread.sleep(500); } String MyMaxBid = driver .findElement(By.xpath("(//a[@href='" + href + "']/following::*[@class='jsMyMaxBidValue'])[1]")) .getText(); String MyMaxBid2 = MyMaxBid.replace(".00", ""); //$8,200.00 String MyMaxBid3 = MyMaxBid2.replace("$", "").replace(",", ""); System.out.println("bidded value is: " + bidValue); System.out.println("showing my bid value is: " + MyMaxBid3); if (MyMaxBid3.equals(bidValue)) resultDetails.setFlag(true); else System.out.println("bid value is mis-matched"); } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void BUYINGQA(WebDriver driver) { try {//w w w . ja v a 2s. c o m QA(driver); 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[2]/ul/li[2]/a")).click(); Thread.sleep(10000); if (driver.getPageSource().contains(getvalue)) { resultDetails.setFlag(true); } } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("Qusetion is not displayed in MyONE"); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void BUYINGMYOFFER(WebDriver driver) { try {//from ww w . j a va2 s . c o m EXACTOFFERINSEARCHRESULTSPAGE(driver); 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[2]/ul/li/a")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); String EQID = driver.findElement(By.xpath("//div[12]/div/div[5]/div/div/div[2]/div/div/div[2]")) .getText(); System.out.println(EQID); if (ID.equalsIgnoreCase(EQID)) { resultDetails.setFlag(true); } } catch (Exception e) { resultDetails.setFlag(false); resultDetails.setErrorMessage("Listing is not displayed in MyOffers section"); } }
From source file:com.java.AppTestType_18_11_2015.java
public void EXACTOFFERINSEARCHRESULTSPAGE(WebDriver driver) { try {//from w ww . ja v a 2s .c o m // suman driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings"); Thread.sleep(1000); driver.findElement(By.linkText("2")).click();//To go to 2nd page of the search results Thread.sleep(10000); //in search result there may be events, so finding first listing(excluding events) to offer exact bid List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']")); int j = -1; for (int i = 1; i < listings.size(); i++) { j++; String s1 = listings.get(i).getAttribute("href"); String s2[] = s1.split("/listing?"); String s3[] = s2[1].split("&"); String s4[] = s3[0].split("="); String id = s4[1]; System.out.println("listing id is: " + id); System.out.println("listing-" + id); String listingText = driver.findElement(By.id("listing-" + id)).getText(); //String Text[]=listingText.split("\n"); System.out.println("text in listing is:................... " + listingText); if (listingText.contains("MAX BID")) { break; } i++; } System.out.println("number of listings in page: " + listings.size()); //taking first listing (not concidering events) WebElement we = listings.get(j); String href = we.getAttribute("href"); System.out.println("href of first listing is: " + href); // (//a[@href='http://e1.dev.assetnation.com/listing?listingid=316696&backToSearchButton=1']/following::*[@class='jsMinOfferjsAmountText'])[1] if (href.contains("http://e1.dev.assetnation.com")) href = href.replaceAll("http://e1.dev.assetnation.com", ""); else if (href.contains("http://e1.dev.assetnation.com/")) href = href.replaceAll("http://e1.dev.assetnation.com/", ""); String min_offer = driver .findElement(By .xpath("(//a[@href='" + href + "']/following::*[@class='jsMinOffer jsAmountText'])[1]")) .getText(); String min_offer2 = min_offer.substring(1, min_offer.length() - 3); String min_offer3 = min_offer2.replace(",", ""); Integer minOffer = Integer.parseInt(min_offer3); System.out.println("minimum offer is: " + minOffer); Integer bidAmount = add + minOffer; String bidValue = String.valueOf(bidAmount); //clicking on exact bid radio button driver.findElement(By.xpath( "(//a[@href='" + href + "']/following::*[@class='check-box' and @value='Exact Bid'])[1]")) .click(); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='text' and @name='makeoffer'])[1]")) .clear(); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='text' and @name='makeoffer'])[1]")) .sendKeys(bidValue); driver.findElement(By .xpath("(//a[@href='" + href + "']/following::*[@type='button' and @value='PLACE A BID'])[1]")) .click(); Thread.sleep(2000); driver.findElement(By.xpath("(//a[@href='" + href + "']/following::*[@class='form-control jsOfferInput e1ConfirmInput' and@type='text'])[1]")) .sendKeys(bidValue); // String ss=driver.findElement(By.xpath("(//a[@href='"+href+"']/following::*[@class='form-control jsOfferInput'])[1]")).getText(); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='button' and @value='CONTINUE'])[1]")) .click(); Thread.sleep(2000); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); //some times we have confirmation check-box and some times we dont have try { driver.findElement(By.xpath("(//input[@class='jsTermsAgree' and @type='checkbox'])[2]")).click(); } catch (Exception e) { System.out.println("there is no confirm check box"); } driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement( By.xpath("(//a[@href='" + href + "']/following::*[@type='submit' and @value='Submit'])[1]")) .click(); Thread.sleep(2000); for (int i = 0; i < 20; i++) { if (driver .findElement( By.xpath("(//a[@href='" + href + "']/following::*[@class='jsMyMaxBidValue'])[1]")) .getText().contains("$")) break; Thread.sleep(500); } String MyMaxBid = driver .findElement(By.xpath("(//a[@href='" + href + "']/following::*[@class='jsMyMaxBidValue'])[1]")) .getText(); String MyMaxBid2 = MyMaxBid.replace(".00", ""); //$8,200.00 String MyMaxBid3 = MyMaxBid2.replace("$", "").replace(",", ""); System.out.println("bidded value is: " + bidValue); System.out.println("showing my bid value is: " + MyMaxBid3); if (MyMaxBid3.equals(bidValue)) resultDetails.setFlag(true); else System.out.println("bid value is mis-matched"); } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void WATCHINGINMYONE(WebDriver driver, String fieldText) { try {/*from w ww.j av a2 s. c om*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); ADDTOWATCHLIST(driver, fieldText); System.out.println("Back to WATCHINGINMYONE method"); driver.findElement(By.xpath("(//a[contains(text(),'MyONE')])[2]")).click(); driver.findElement(By.xpath("(//a[contains(text(),'Watching')])[2]")).click(); if (driver.getPageSource().contains(ListingID)) { System.out.println("listing is found in myone pagesource"); resultDetails.setFlag(true); } } catch (Exception e) { System.out.println("Listing added is not displayed in MYOne Watchlist"); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void ADDTOWATCHLIST(WebDriver driver, String fieldText) { String fieldType = fieldText; String field = fieldText;/* ww w. j a v a 2 s. c o m*/ try { AppKeyWords cdf = AppKeyWords.valueOf(fieldType.toUpperCase()); switch (cdf) { case FROMSEARCH: try { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 25); //navigation to next page driver.findElement(By.linkText("2")).click(); //Thread.sleep(5000) wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]"))); //clicking on first binocular icon which is not yet watching ListingID = driver.findElement(By.xpath( "(//*[@class='e1tooltip icon_watchlist']/../following::div[@class='rgbold jsLotID myone-black'])[2]")) .getText(); System.out.println(ListingID); driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click(); Thread.sleep(1000); resultDetails.setFlag(true); } catch (Exception e) { resultDetails.setFlag(false); } break; case FROMLISTING: try { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("2")).click();//To go to 2nd page of the search results driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist']/../../a[1])[1]")).click(); ; //ListingID = driver.findElement(By.xpath("//*[contains(text(),'Lot ID:')]/span")).getText(); ListingID = driver.findElement(By.xpath("//*[@class='e2lot-result rgbold jsLotID']")).getText(); System.out.println(ListingID); driver.findElement(By.linkText("Watch This")).click(); System.out.println("clicked on watch this"); System.out.println(driver.findElement(By.xpath("//*[@class='e1WatchingThisText']")).getText()); if (driver.findElement(By.xpath("//*[@class='e1WatchingThisText']")).getText() .equalsIgnoreCase("Watching")) { System.out.println("Added to watchlist"); resultDetails.setFlag(true); } else { resultDetails.setFlag(false); System.out.println("listing is not added to watchlist1"); } System.out.println("going out of ADDTOWATCHLIST method"); } catch (Exception e) { resultDetails.setFlag(false); e.printStackTrace(); } break; case FROMEVENTPAGE: try { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); List<WebElement> events = driver .findElements(By.xpath("//a[@class='jsTitle' and contains(@href,'/event?eventid')]")); System.out.println("event size is: " + events.size()); Random r = new Random(); /*int randomValue = r.nextInt(listings.size()); //Getting a random value that is between 0 and (list's size)-1 */ WebDriverWait wait = new WebDriverWait(driver, 20); //selecting random event and trying to bid on first listing, if the event doesn't have open listings it will try with next event for (int i = 0; i < events.size(); i++) { events.get(r.nextInt(events.size())).click(); Thread.sleep(8000); if (driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")) .isDisplayed()) { //clicking on first binocular icon which is not yet watching ListingID = driver.findElement(By.xpath( "(//*[@class='e1tooltip icon_watchlist']/../following::div[@class='rgbold jsLotID myone-black'])[2]")) .getText(); System.out.println(ListingID); driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click(); Thread.sleep(1000); resultDetails.setFlag(true); break; } //go back to event page else driver.navigate().back(); } } catch (Exception e) { resultDetails.setFlag(false); e.printStackTrace(); } break; } } catch (Exception e) { e.printStackTrace(); System.out.println("listing is not added to watchlist2"); resultDetails.setFlag(false); } }