com.mycompany.selenium.factory.pages.Google.ResultsPage.java Source code

Java tutorial

Introduction

Here is the source code for com.mycompany.selenium.factory.pages.Google.ResultsPage.java

Source

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.mycompany.selenium.factory.pages.Google;

    import com.mycompany.selenium.factory.Page;
    import com.mycompany.selenium.factory.tests.Init;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.support.FindBy;
    import org.openqa.selenium.support.PageFactory;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

/**
 *
 * @author sidochenko
 */
public class ResultsPage extends Page {
    private final static String title = "";

    @FindBy(name = "text")
    public WebElement searchBar;

    @FindBy(xpath = "//h3/a")
    public WebElement firstLink;


    public ResultsPage() {
        PageFactory.initElements(Init.getDriver(), this);
        (new WebDriverWait(Init.getDriver(), 10))
                .until(ExpectedConditions.presenceOfElementLocated(By.id("resultStats")));

    }

    @Override
    public String getTitle() {
        return title;
    }

    public void ___??() {
        String currentWindow = Init.getDriver().getWindowHandle();
        firstLink.click();
        Init.getDriver().switchTo().window(currentWindow).close();
        Init.getDriver().switchTo().window((String) Init.getDriver().getWindowHandles().toArray()[0]);

    }

}