selenium interview screening questions code example

Example 1: selenium interview questions 2019

from selenium import webdriver

PROXY = "10.0.0.10:8080" # IP:PORT or HOST:PORT

chrome_opt = webdriver.ChromeOptions()
chrome_opt.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(options=chrome_opt)
chrome.get("<< target URL >>")

Example 2: 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 3: selenium interview questions 2019

Import org.apache.commons.io.FileUtils;
WebDriver ins = new ChromeDriver();
ins.get("http://www.google.com/");

File screen = ((TakesScreenshot)ins).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere

FileUtils.copyFile(screen, new File("c:\tmp\myscreen.png"));