Change execution speed in Java (Set Speed)
Create a new class "_WebDriver" which extends FireFoxDriver. Inside "_WebDriver" class override method "findElement" and introduce a delay inside it.
public class Main_class{
public static void main(String[] args)
{
WebDriver driver=new _WebDriver(200);
driver.get("https://in.yahoo.com/");
driver.findElement(By.id("UHSearchBox")).sendKeys("address1");
driver.findElement(By.id("UHSearchWeb")).click();
}
}
//---------Create a new Java File
public class _WebDriver extends FirefoxDriver {
private int set_speed=0;
public _WebDriver(int set_speed) //Constructor to initialize the speed
{
this.set_speed=set_speed;
}
@Override
public WebElement findElement(By by) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
return by.findElement((SearchContext) this);
}
}
No comments:
Post a Comment