selenium java interview questions 10 years code example

Example 1: selenium interview questions 2019

public class LogInPage
{
    @FindBy(id="userName")
    private WebElement user;

    @FindBy(id="password")
    private WebElement pass;

    public LogInPage() {
        PageFactory.initElements(browser, this); // Setup the members as browser.findElement()
    }

    public void processLogIn() {
        user.sendKeys("john");
        pass.sendKeys("password");
    }
}

Example 2: selenium interview questions 2019

// Set up the JS object
JavascriptExecutor jscript = (JavascriptExecutor)webdriver;
// Issue command to enter the text
jscript.executeScript("document.getElementById('textbox').value = 'Some Text';");

Tags:

Misc Example