Can anyone advice me any alternative for Thread.sleep(0, when ever I'm taking it off, my test is failing as the element is not found.
@BeforeMethod
public static void setUp() throws Exception {
System.out.println("Common @BeforeMethod setUp");
driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.get(baseUrl);
}
I also wrote a method for delay but when ever I'm calling it , it's not giving me the alternative of Thread.sleep(),
For my test case, the scenario is , I need to select a tab from some menu , then directing to that page,then selecting item from drop down boxes, then based on that I need to click on search button. Now I definitely need some wait method. But I don't know what can I use as an alternative to Thread.sleep!
public static void explicitWait(final String locator, final int type) {
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(new ExpectedCondition<WebElement>(){
public WebElement apply(WebDriver d) {
switch (type) {
case 1 : return d.findElement(By.cssSelector(locator));
case 2 : return d.findElement(By.xpath(locator));
case 3 : return d.findElement(By.id(locator));
case 4 : return d.findElement(By.name(locator));
case 5 : return d.findElement(By.linkText(locator));
default:
return d.findElement(By.id(locator));
}
}});
}
Any help will be highly appreciated.
--
Regards.
Tanusree