Example usage for org.openqa.selenium By name

List of usage examples for org.openqa.selenium By name

Introduction

In this page you can find the example usage for org.openqa.selenium By name.

Prototype

public static By name(String name) 

Source Link

Usage

From source file:com.ipinyou.webpage.del.DelAdvertiserPage.java

public static void create(WebDriver driver, AdvertiserInfo adinfo, int a) throws NoSuchElementException {

    driver.findElement(By.className("resource-create-btn")).click();
    driver.findElement(By.id("advertiser.name")).sendKeys(adinfo.adname);
    driver.findElement(By.id("advertiser.registerName")).sendKeys(adinfo.registername);
    if (a == 1) {
        driver.findElement(By.id("advertiser.serviceFeeRate")).sendKeys(adinfo.servicefeerate);
    }//from   www. j  a v a2s  .c o m
    //      driver.findElement(By.id("advertiser.selfService1")).click();
    //      driver.findElement(By.id("advertiser.selfService0")).click();
    Select industry = new Select(driver.findElement(By.name("advertiser.verticalTagId")));
    industry.selectByVisibleText(adinfo.industrytext);
    WebElement websuite = driver.findElement(By.id("advertiser.website"));
    websuite.clear();
    websuite.sendKeys(adinfo.advertiserwebsite);
    driver.findElement(By.id("advertiser.cellphone")).sendKeys(adinfo.cellphone);
    driver.findElement(By.id("advertiser.contactName")).sendKeys(adinfo.contactname);
    driver.findElement(By.id("advertiser.type0")).click();
    driver.findElement(By.id("advertiser.email")).sendKeys(adinfo.email);
    driver.findElement(By.id("advertiser.showLogo1")).click();
    driver.findElement(By.id("advertiser.showLogo0")).click();
    WebElement addaptitude = driver.findElement(By.id("addQualificationFiles"));
    addaptitude.click();
    if (a == 2) {
        addaptitude.click();
    } else {
        ;
    }
    //ICP
    Select aptitudeicp = new Select(driver.findElement(By.name("types")));
    aptitudeicp.selectByValue("ICP");
    driver.findElement(By.name("qualifications")).sendKeys(adinfo.path);
    addaptitude.click();
    //
    Select aptitudelicense = new Select(driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/select")));
    aptitudelicense.selectByValue("License");
    WebElement chooselicense = driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/input"));
    chooselicense.sendKeys(adinfo.path);
    addaptitude.click();
    //
    Select aptitudelegalid = new Select(driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/select")));
    aptitudelegalid.selectByValue("LegalId");
    WebElement chooselegalid = driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/input"));
    chooselegalid.sendKeys(adinfo.path);

    addaptitude.click();
    //
    Select aptitudeproduct = new Select(driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/select")));
    aptitudeproduct.selectByValue("Product");
    WebElement chooseproduct = driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/input"));
    chooseproduct.sendKeys(adinfo.path);

    addaptitude.click();
    //
    Select aptitudeother = new Select(driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/select")));
    aptitudeother.selectByValue("Other");
    WebElement chooseother = driver
            .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/input"));
    chooseother.sendKeys(adinfo.path);

    WebElement submit = driver.findElement(By.name("submitForm"));
    submit.click();
}

From source file:com.jaliansystems.customiSE.example.TestCalc.java

License:Apache License

@Before
public void setup() throws IOException {
    String javaExe = findJavaExe();
    if (javaExe != null)
        System.setProperty(CustomiSEDriverService.JAVA_EXE_PROPERTY, javaExe);
    System.out.println("TestCalc.setup(" + javaExe + ")");
    CustomiSEDriverService service = new CustomiSEDriverService.Builder()
            .withAgentImplementation(CalculatorAgent.class.getName())
            .addClasspathEntry(new File(findClassPathFor(CalculatorAgent.class)))
            .addClasspathEntry(new File(findClassPathFor(Calc.class)))
            .addJreProperty(CustomiSEDriverService.JAVA_EXE_PROPERTY, javaExe).build();
    driver = new CustomiSEDriver(service);

    // @formatter:off
    String[] ops = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "c", "=", "/", "*", "-",
            "+", "value" };
    // @formatter:on
    elements = new HashMap<>();
    for (String op : ops) {
        elements.put(op, driver.findElement(By.name(op)));
    }/*from   w  w w  .jav a2 s  . c o  m*/
}

From source file:com.java.AppTestType_18_11_2015.java

public void ELISTINGS(WebDriver driver) { //Equipment and Accessories listings creation from selfservice.

    try {// ww w. j  av  a  2  s .co  m

        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 APPROVEDLG(WebDriver driver) {

    try {//from  ww  w  . j  av  a  2s . c om

        String parent = driver.getWindowHandle();

        System.out.println(parent);

        driver.findElement(By.linkText("Approve")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        ;

        driver.switchTo().window("changeSTatus");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        ;

        driver.findElement(By.name("reason")).sendKeys("approve");

        driver.findElement(By.name("verify")).click();

        driver.findElement(By.xpath("//input[@value='Approve']")).click();

        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        ;
        driver.switchTo().window(parent);

        LOTNUMBER = driver.findElement(By.xpath("//td[4]")).getText();
        System.out.println(LOTNUMBER);

        driver.findElement(By.linkText("Logout")).click();

        driver.manage().deleteAllCookies();
        driver.navigate().refresh();

        resultDetails.setFlag(true);
    }

    catch (Exception e) {

        resultDetails.setFlag(false);
    }
}

From source file:com.java.AppTestType_18_11_2015.java

public void READCSV(WebDriver driver) {

    driver.get("http://mmtool.staging.assetnation.com"); // Change again back to staging AMP Site.
    driver.manage().deleteAllCookies();/*from w  ww . j av a2  s.  com*/
    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.findElement(By.linkText("Users")).click();

    /* reading of Excel file and saving into Array. */

    Scanner s = new Scanner(System.in);

    try {

        File f = new File("E:/JMeter/fullusers.txt");

        Scanner numScan = new Scanner(f);

        String line;

        while (numScan.hasNext()) {
            line = numScan.nextLine();
            System.out.print(line + " ");

            driver.findElement(By.name("email")).sendKeys(line);

            driver.findElement(By.xpath("//input[@value='Search']")).click();

            driver.findElement(By.xpath("//td/a")).click();
            Thread.sleep(10000);

            String ParentHandle = driver.getWindowHandle();
            driver.findElement(By.linkText("Approve User")).click();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            ;
            driver.switchTo().alert().accept();
            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.switchTo().alert().accept();
            Thread.sleep(10000);
            driver.switchTo().window(ParentHandle);

            driver.findElement(By.linkText("Users")).click();

            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        }

        resultDetails.setFlag(true);

    } catch (Exception e) {

    }

}

From source file:com.java.AppTestType_18_11_2015.java

public String QA(WebDriver driver) throws FileNotFoundException, InterruptedException {

    try {/*from   ww  w.j  a va 2  s .c o  m*/

        driver.findElement(By.linkText("ALL EQUIPMENT")).click();

        Thread.sleep(10000);

        List<WebElement> listings = driver.findElements(By.cssSelector("a[href*='/listing?listingid']"));

        Random r = new Random();

        int randomvalue = r.nextInt(listings.size());
        listings.get(randomvalue).click();

        System.out.println(randomvalue);

        getvalue = driver.findElement(By.xpath("//div[7]/span")).getText();
        System.out.println(getvalue);

        driver.findElement(By.xpath("//div[3]/div[2]/input")).click();
        Thread.sleep(10000);

        driver.findElement(By.id("listingQuestion")).click();
        Thread.sleep(10000);

        driver.findElement(By.id("listingQuestion")).sendKeys("where is the listing located");
        Thread.sleep(10000);
        driver.findElement(By.name("submitq")).click();
        Thread.sleep(10000);

        driver.findElement(By.xpath("//div/div[2]/div[3]/input")).click();
        Thread.sleep(10000);

        //          
        resultDetails.setFlag(true);

    } catch (StaleElementReferenceException e) {

        if (retries < MAX_STALE_ELEMENT_RETRIES) {

            retries++;
        }

        else {

            throw e;
        }

    }
    return getvalue;

}

From source file:com.java.AppTestType_18_11_2015.java

public void VERIFYQAINAMP(WebDriver driver, String fieldText) throws FileNotFoundException {

    String field = fieldText;/* ww  w  .ja va 2  s .c o  m*/

    try {

        // driver.findElement(By.linkText("ALL EQUIPMENT")).click();
        /* driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings");
        driver.findElement(By.linkText("2")).click();
                
        Thread.sleep(10000);
                
        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);*/
        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 = "Where is the listing located?" + Time;
        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(field);
        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();

        if (driver.getPageSource().contains(question)) {
            //driver.navigate().refresh();
            resultDetails.setFlag(true);
        } else
            System.out.println("question not found in AMP");

    } catch (Exception e) {
        e.printStackTrace();
        resultDetails.setFlag(false);

        //       FileOutputStream fos = new FileOutputStream("C:/TestProject - DEV/Log File/logfile.txt");
        //        PrintStream ps = new PrintStream(fos);
        //        e.printStackTrace(ps);
    }
}

From source file:com.java.AppTestType_18_11_2015.java

public void REJECTQUES(WebDriver driver, String fieldText) {

    try {//www  . j  a  v a2  s . 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 = "Can You Reject This Question?";
        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("Reject")));

        String ParentHandle = driver.getWindowHandle();
        driver.findElement(By.linkText("Reject")).click();
        for (String winHandle : driver.getWindowHandles()) {

            System.out.println("Entered For Loop");
            driver.switchTo().window(winHandle);
        }

        driver.findElement(By.id("id_button_rejct")).click();

        Thread.sleep(10000);

        driver.switchTo().alert().accept();
        Thread.sleep(2000);
        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);
        e.printStackTrace();
    }
}

From source file:com.java.AppTestType_18_11_2015.java

public void FORWARDTOMM(WebDriver driver, String fieldText) {

    try {/*ww w . j a v a 2s  . 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 MM?";
        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 MM')]")).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("MM is not displayed for this listing");
        e.printStackTrace();
    }

}

From source file:com.java.AppTestType_18_11_2015.java

public void FORWARDTOSELLER(WebDriver driver, String fieldText) {

    try {//from   w w w  .jav a2 s  . com

        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.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(10000);
        driver.findElement(By.xpath("//*[contains(@onclick,'FORWARDED TO SELLER')]")).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 (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();
    }

}