Example usage for org.openqa.selenium WebDriver manage

List of usage examples for org.openqa.selenium WebDriver manage

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver manage.

Prototype

Options manage();

Source Link

Document

Gets the Option interface

Usage

From source file:com.java.AppTestType_18_11_2015.java

public void MAXBIDFROMEVENTPAGE(WebDriver driver) {

    try {//  w ww .ja v a 2s  . com
        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("(//*[contains(@value,'PLACE A BID')])[2]")).isDisplayed()) {
                driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click();
                BIDDING_IN_LISTINGDETAILSPAGE(driver);
                resultDetails.setFlag(true);
                break;
            }
            //go back to event page
            else
                driver.navigate().back();

        }

    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Listing is not available or Closed");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void EXACTBIDFROMEVENTPAGE(WebDriver driver) {

    try {/*from   w w w . j ava 2 s.  c o  m*/
        System.out.println("Enterd to EXACTBIDFROMEVENTPAGE ");
        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);
            //wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]"))));
            if (driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).isDisplayed()) {
                driver.findElement(By.xpath("(//*[@type='radio' and @value='Exact Bid'])[2]")).click();
                Thread.sleep(4000);
                driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click();
                BIDDING_IN_LISTINGDETAILSPAGE(driver);
                resultDetails.setFlag(true);
                break;
            }
            //go back to event page
            else
                driver.navigate().back();

        }

    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Listing is not available or Closed");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void EXACTBIDFROMWATCHINGPAGE(WebDriver driver) {

    try {/*from ww  w .j  a  va2s. c o  m*/
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings");
        WebDriverWait wait = new WebDriverWait(driver, 25);
        Thread.sleep(1000);
        //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
        driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click();
        //Thread.sleep(5000);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("(//a[text()='MyONE '])[2]")));
        driver.findElement(By.xpath("(//a[text()='MyONE '])[2]")).click();
        //Thread.sleep(5000);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText("Watching")));

        driver.findElement(By.partialLinkText("Watching")).click();
        if (wait.until(ExpectedConditions
                .presenceOfElementLocated(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")))
                .isDisplayed()) {
            driver.findElement(By.xpath("(//*[@type='radio' and @value='Exact Bid'])[2]")).click();
            Thread.sleep(4000);
            driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click();
            BIDDING_IN_LISTINGDETAILSPAGE(driver);
            resultDetails.setFlag(true);
        } else {
            System.out.println("there is no place a bid button in watchlist section");
        }
    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Listing is not available or Closed");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void MAXBIDFROMWATCHINGPAGE(WebDriver driver) {

    try {//ww w.j  a v a  2 s . c  o m
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings");
        WebDriverWait wait = new WebDriverWait(driver, 25);
        Thread.sleep(1000);
        //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
        driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click();
        //Thread.sleep(5000);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("(//a[text()='MyONE '])[2]")));
        driver.findElement(By.xpath("(//a[text()='MyONE '])[2]")).click();
        //Thread.sleep(5000);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText("Watching")));

        driver.findElement(By.partialLinkText("Watching")).click();
        if (wait.until(ExpectedConditions
                .presenceOfElementLocated(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")))
                .isDisplayed()) {

            driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click();
            BIDDING_IN_LISTINGDETAILSPAGE(driver);
            resultDetails.setFlag(true);
        } else {
            System.out.println("there is no 'place a bid button' in watchlist section");
        }
    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Listing is not available or Closed");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void BIDDING_IN_LISTINGDETAILSPAGE(WebDriver driver) {

    try {//from  www  .j  a  v a2s  . c  om
        int k = 0;
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        String offer_withdollar = driver.findElement(By.xpath("(//span[@class='jsMinOffer jsAmountText'])[2]"))
                .getText();

        String offer1 = offer_withdollar.replace("$", "");
        String offer = offer1.substring(0, offer1.length() - 3).replace(",", "");
        Integer a = Integer.parseInt(offer);
        System.out.println("you need to enter: " + offer);

        driver.findElement(By.xpath("(//input[@class='form-control jsOfferInput e1ConfirmInput'])[2]"))
                .sendKeys(offer);
        driver.findElement(By.xpath("(//input[@class='btn btn-primary jsConfirmOffer'])[2]")).click();

        //CHECKING CALCULATION PART
        Thread.sleep(4000);
        String total_amount = driver
                .findElement(
                        By.xpath("(//*[@class='col-sm-12 col-xs-12 text-right myone-green jsBidTotal'])[2]"))
                .getText();
        Integer total_amount2 = Integer
                .parseInt(total_amount.substring(1, total_amount.length() - 3).replace(",", ""));
        /*int act_amount=(int) total_amount2;
        int exp_amount=(int) (a*1.1);
                
        if(act_amount!=exp_amount)
           k=1;*/

        //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");
        }
        Thread.sleep(5000);
        driver.findElement(By.xpath("(//input[@class='btn btn-primary jsSubmitOffer'])[2]")).click();
        //verifying my max amount
        Thread.sleep(3000);
        String nextoffer = driver.findElement(By.xpath("(//span[@class='jsMinOffer jsAmountText'])[2]"))
                .getText();
        if (offer_withdollar.equalsIgnoreCase(nextoffer)) //if(offer_withdollar.equalsIgnoreCase(nextoffer) || k==1)
            resultDetails.setFlag(false);
        else
            resultDetails.setFlag(true);

    } catch (Exception e) {
        e.printStackTrace();
        resultDetails.setFlag(false);
        resultDetails.setErrorMessage("unsuccessful bid");
    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void BIDAMOUNTCALCULATION(WebDriver driver, String fieldText) {

    try {//from  w  w w .  j  av a2s  . c  o  m

        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        WebDriverWait wait = new WebDriverWait(driver, 25);
        String page = fieldText;
        switch (page) {

        case "LOTPAGE":

            if (wait.until(ExpectedConditions
                    .presenceOfElementLocated(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")))
                    .isDisplayed()) {
                driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click();

                driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
                String offer_withdollar = driver
                        .findElement(By.xpath("(//span[@class='jsMinOffer jsAmountText'])[2]")).getText();

                String offer1 = offer_withdollar.replace("$", "");
                String offer = offer1.substring(0, offer1.length() - 3).replace(",", "");
                Integer a = Integer.parseInt(offer);
                System.out.println("you need to enter: " + offer);

                driver.findElement(By.xpath("(//input[@class='form-control jsOfferInput e1ConfirmInput'])[2]"))
                        .sendKeys(offer);
                driver.findElement(By.xpath("(//input[@class='btn btn-primary jsConfirmOffer'])[2]")).click();

                //CHECKING CALCULATION PART
                Thread.sleep(4000);
                String total_amount = driver
                        .findElement(By.xpath(
                                "(//*[@class='col-sm-12 col-xs-12 text-right myone-green jsBidTotal'])[2]"))
                        .getText();
                Integer total_amount2 = Integer
                        .parseInt(total_amount.substring(1, total_amount.length() - 3).replace(",", ""));
                int t1 = (int) (a + a * 0.1);
                int t2 = (int) total_amount2;

                System.out.println("Expected total amount including buyer premium is: " + t1);
                System.out.println("Actual amount is: " + t2);

                if (t1 == t2) {
                    resultDetails.setFlag(true);
                }

            } else {
                System.out.println("there is no 'place a bid button");
            }

            break;

        case "LOTDETAILSPAGE":
            if (wait.until(ExpectedConditions
                    .presenceOfElementLocated(By.xpath("(//*[contains(text(),'Place Bid')])"))).isDisplayed()) {
                driver.findElement(By.xpath("(//*[contains(text(),'Place Bid')])")).click();

                driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
                String offer_withdollar = driver.findElement(By.xpath("(//span[@class='jsMinOffer'])"))
                        .getText();

                String offer1 = offer_withdollar.replace("$", "");
                String offer = offer1.substring(0, offer1.length() - 3).replace(",", "");
                Integer a = Integer.parseInt(offer);
                System.out.println("you need to enter: " + offer);

                driver.findElement(By.xpath("(//input[@class='jsOfferInput e1ConfirmInput'])[1]"))
                        .sendKeys(offer);
                driver.findElement(By.xpath("(//button[@class='e1Buttons jsConfirmOffer e1OrangeShadow'])[1]"))
                        .click();

                //CHECKING CALCULATION PART
                Thread.sleep(4000);
                String total_amount = driver.findElement(By.xpath("(//*[@class='jsBidTotal'])[1]")).getText();
                Integer total_amount2 = Integer
                        .parseInt(total_amount.substring(1, total_amount.length() - 3).replace(",", ""));
                int t1 = (int) (a + a * 0.1);
                int t2 = (int) total_amount2;

                System.out.println("Expected total amount including buyer premium is: " + t1);
                System.out.println("Actual amount is: " + t2);

                if (t1 == t2) {
                    resultDetails.setFlag(true);
                }

            } else {
                System.out.println("there is no 'place a bid button");
            }
            break;

        }
    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Listing is not available or Closed");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void E1LISTINGSELECTION(WebDriver driver, String value) throws InterruptedException {

    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    int k = 0;//from w  w  w  .  j  a v a 2s.  com
    for (int i = 0; i < 10; i++) {
        if (driver
                .findElements(
                        By.xpath("(//a[@class='jsImageLink' and contains(@href,'/listing?listingid')])[1]"))
                .size() > 0) {
            if (value.equalsIgnoreCase("CLK"))
                driver.findElement(
                        By.xpath("(//a[@class='jsImageLink' and contains(@href,'/listing?listingid')])[1]"))
                        .click();
            k = 1;
            break;
        } else {
            driver.findElement(By.xpath("(//*[text()='Next Page'])[1]")).click();

        }

        Thread.sleep(10000);
    }
    if (k == 1)
        resultDetails.setFlag(true);

}

From source file:com.java.AppTestType_18_11_2015.java

public void VISIBLE(WebDriver driver, String fieldText, String value) {
    //To verify whetheer a locator is visible
    //FieldText---Locator
    //value----Time in ms
    try {//from w w  w  .j av  a2s. co m
        String f = fieldText;
        String locatorType = f.substring(0, 3);
        String locatorValue = f.substring(3, f.length());
        String val1 = value;
        int val = Integer.parseInt(val1);
        driver.manage().timeouts().implicitlyWait(val, TimeUnit.MILLISECONDS);
        if (locatorType.equalsIgnoreCase("XPH")) {
            //System.out.println(driver.findElement(By.xpath(locatorValue)).getText());  
            if (driver.findElement(By.xpath(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);
        } else if (locatorType.equalsIgnoreCase("LNK")) {

            if (driver.findElement(By.linkText(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("IDI") || locatorType.equalsIgnoreCase("TXT")) {

            if (driver.findElement(By.id(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("MSG")) {

            if (driver.findElement(By.xpath("//*[contains(text(),'" + locatorValue + "')]")).isDisplayed())
                resultDetails.setFlag(true);
        }
    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Element is Not Visible");
        resultDetails.setFlag(false);

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void NOTVISIBLE(WebDriver driver, String fieldText, String value) {
    //To verify whetheer a locator is NOT visible
    //FieldText---Locator
    //value----Time in ms
    try {//from w  ww  .j  a v  a2 s. co  m
        String f = fieldText;
        String locatorType = f.substring(0, 3);
        String locatorValue = f.substring(3, f.length());
        String val1 = value;
        int val = Integer.parseInt(val1);
        driver.manage().timeouts().implicitlyWait(val, TimeUnit.MILLISECONDS);
        if (locatorType.equalsIgnoreCase("XPH")) {
            //System.out.println(driver.findElement(By.xpath(locatorValue)).getText());  
            if (!driver.findElement(By.xpath(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);
        } else if (locatorType.equalsIgnoreCase("LNK")) {

            if (!driver.findElement(By.linkText(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("IDI") || locatorType.equalsIgnoreCase("TXT")) {

            if (!driver.findElement(By.id(locatorValue)).isDisplayed())
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("MSG")) {

            if (!driver.findElement(By.xpath("//*[contains(text(),'" + locatorValue + "')]")).isDisplayed())
                resultDetails.setFlag(true);
        }
    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Element is Visible");
        resultDetails.setFlag(false);
    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void VERIFYNOT(WebDriver driver, String fieldText, String value) {
    //To verify that the locator doesn't exist
    //FieldText---Locator
    //value----Time in ms
    //Give lesser Time like 2000,or else the execution will wait that much time
    try {//w ww .j  av a2s.  c  o  m

        String f = fieldText;
        String time = value;
        String locatorType = f.substring(0, 3);
        String locatorValue = f.substring(3, f.length());
        int timevalue = Integer.parseInt(time);

        driver.manage().timeouts().implicitlyWait(timevalue, TimeUnit.MILLISECONDS);

        if (locatorType.equalsIgnoreCase("XPH")) {
            if (driver.findElements(By.xpath(locatorValue)).size() == 0)
                resultDetails.setFlag(true);
        } else if (locatorType.equalsIgnoreCase("LNK")) {

            if (driver.findElements(By.linkText(locatorValue)).size() == 0)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("IDI") || locatorType.equalsIgnoreCase("TXT")) {

            if (driver.findElements(By.id(locatorValue)).size() == 0)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("MSG")) {

            int j = 0;
            int t = timevalue / 1000;
            for (int i = 0; i < t; i++) {
                if (driver.findElements(By.xpath("//*[contains(text(),'" + locatorValue + "')]")).size() == 0) {
                    j = 1;
                    break;
                }
                Thread.sleep(1000);

            }
            if (j == 1)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("PLK")) {

            if (driver.findElements(By.partialLinkText(locatorValue)).size() == 0)
                resultDetails.setFlag(true);

        }

    } catch (Exception e) {

        e.printStackTrace();
        resultDetails.setErrorMessage("Element is Present");
        resultDetails.setFlag(false);
    }

}