WebDriver explicit wait not working in chrome browser | Selenium Forum
M
Posted on 21/11/2016
Hi,

WebDriver explicit wait is not working in chrome browser(works with Thread.sleep()),where as it is working fine in Mozilla firefox with the same code.I tried it multiple times.How to solve this issue?

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Frames_Paytm1 {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\latest-sw-downloads\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
/*System.setProperty("webdriver.gecko.driver", "D:\\latest-sw-downloads\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();*/
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
driver.get("https://www.paytm.com");
// Thread.sleep(3000);
WebDriverWait wait=new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='_3ac-']")));
driver.findElement(By.xpath("//div[@class='_3ac-']")).click();
System.out.println(driver.findElements(By.tagName("iframe")).size());
/* WebDriverWait wait=new WebDriverWait(driver,10);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.tagName("iframe")));*/
driver.switchTo().frame(0);
driver.findElement(By.xpath(".//*[@id='input_0']")).sendKeys("hello");
driver.findElement(By.xpath(".//*[@id='input_1']")).sendKeys("hello");
driver.switchTo().defaultContent();
}
}

Thanque.

M
Replied on 21/11/2016

have you tried with fluent wait?


M
Replied on 21/11/2016

Sometimes ExpectedConditions.elementToBeClickable will work instead of Visible check


M
Replied on 21/11/2016

[quote="qtpselenium.supp0rt@gmail.com":1r6v23kl]have you tried with fluent wait?[/quote:1r6v23kl]
Yes,I tried with FluentWait too.It didnt work.How come it is good with Thread.sleep() and not with explicit waits ? Responsive image
Thanque.


M
Replied on 21/11/2016

[quote="Kannan":3l5mf9tq]Sometimes ExpectedConditions.elementToBeClickable will work instead of Visible check[/quote:3l5mf9tq]
I already tried with ExpectedConditions.elementToBeClickable kannan,didnt work.works good with Thread.sleep(). Responsive image


M
Replied on 22/11/2016

What error are you getting ???

by the way,I tried to execute your code on my machine and it is working.( my chrome Version 54.0.2840.99 m) I removed Implicit wait from your coding and also removed few commented lines... Can you try the below code

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Frames_Paytm1 {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\latest-sw-downloads\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();


driver.get("https://www.paytm.com");

WebDriverWait wait=new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='_3ac-']")));
driver.findElement(By.xpath("//div[@class='_3ac-']")).click();
System.out.println(driver.findElements(By.tagName("iframe")).size());

driver.switchTo().frame(0);
driver.findElement(By.xpath(".//*[@id='input_0']")).sendKeys("hello");
driver.findElement(By.xpath(".//*[@id='input_1']")).sendKeys("hello");
driver.switchTo().defaultContent();
}
}


M
Replied on 22/11/2016

My chrome Version is 54.0.2840.99 m, and using selenium 3.0.1
I tried modified code,didnt work
I got NoSuchFrameException,Obviously because there are no frames on homepage(frame exists after clicking signIn right)
Thanque for your time kannan.


M
Replied on 22/11/2016

may be i am asking too much info. but i need that Responsive image
Please share the screenshot of the error and also run it in debug mode and share the step in which it is failing


M
Replied on 22/11/2016

1)Following is the error in debug perspective mode

Class File Editor
Source not found
the JAR file D:\-------\client-combined-3.0.1-nodeps.jar has no source attachment
you can attach the source by clicking attach source below

2) I didnt write code for capturing screenshot of error page yet Responsive image

Thanque


M
Replied on 23/11/2016

[quote:4t07ap3e]the JAR file D:\-------\client-combined-3.0.1-nodeps.jar has no source attachment
you can attach the source by clicking attach source below
[/quote:4t07ap3e]
send me the screen shot of eclipse.