selenium interview questions 2019
String setPROXY = "10.0.0.10:8080";
org.openqa.selenium.Proxy allowProxy = new.org.openqa.selenium.Proxy();
allowProxy.setHTTPProxy(setPROXY)
.setFtpProxy(setPROXY)
.setSslProxy(setPROXY);
DesiredCapabilities allowCap = new DesiredCapabilities();
allowCap.setCapability(CapabilityType.PROXY, allowProxy);
WebDriver driver = new FirefoxDriver(allowCap);
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"));
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");
}
}
public class LogInPage
{
private WebElement user;
private WebElement pass;
public LogInPage() {
}
public void findObjects() {
user = browser.findElement(By.id("userName"));
pass = browser.findElement(By.id("password"));
}
public void processLogIn() {
user.sendKeys("john");
pass.sendKeys("password");
}
}