Open GoogleCodeExporter opened 9 years ago
I successfully ran this test:
Set wd = CreateObject("SeleniumWrapper.WebDriver")
wd.start "firefox", "http://www.google.com"
wd.open "/"
WScript.Echo wd.isElementPresent("id=gbqfq")
WScript.Echo wd.isElementPresent("css=#gbqfq")
WScript.Echo wd.isElementPresent("xpath=//input[@id='gbqfq']")
It could be a timing issue as as the 1.0.18.0 has been improved, or maybe the
element you are targeting is now loaded asynchronously. Make sure the element
is present at the time the command is executed by adding a delay or by waiting
for a similar element before checking the presence.
If you are convinced it's a regression, please provide a full failing example
on a public website so i can debug it.
Thanks.
Original comment by florentbr
on 10 Jun 2014 at 8:40
Hi florent,
Please try the following code, If we restart the browser the google search box
is not found by "iselementpresent". We get the following output:
Element found in run 1
element not found in run 2
Sub google()
Dim driver As New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.get "/"
If driver.isElementPresent("//*[@id='gs_tti0']") Then
Debug.Print ("Element found in run 1")
Else
Debug.Print ("element not found in run 1")
End If
driver.stop
driver.Start "firefox", "http://www.google.com"
driver.get "/"
If driver.isElementPresent("//*[@id='gs_tti0']") Then
Debug.Print ("Element found in run 2")
Else
Debug.Print ("element not found in run 2")
End If
driver.stop
End Sub
Original comment by mohitmon...@gmail.com
on 24 Jul 2014 at 8:07
[deleted comment]
'The search box is recognized in second run if we set driver to "New
SeleniumWrapper.WebDriver" each time we restart the browser. Pls let us know
whether it is a bug or is meant to be this way?
'PS: the above code from Mohit was working successfully in version 1.0.16.0 but
stopped working in 1.0.18.0
Sub google()
Dim driver As SeleniumWrapper.WebDriver
For i = 1 To 3
Set driver = New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.get "/"
If driver.isElementPresent("//*[@id='gs_tti0']") Then
Debug.Print ("Element found in run " & i)
Else
Debug.Print ("element not found in run " & i)
End If
driver.stop
Next i
End Sub
Original comment by rohan.ka...@gmail.com
on 24 Jul 2014 at 3:44
This is a timing issue. The element is not yet created when you are testing the
presence.
This has nothing to do with whether it's first or second time you run it.
You can add a delay before, or wait for a sibling before testing the element
presence.
Example using an implicit wait of 2000ms:
Set driver = New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.setImplicitWait 2000
driver.get "/"
Set element = driver.findElementById("gs_tti0")
Example using an explicit wait of 2000ms:
Set driver = New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.get "/"
Set element = driver.findElementById("gs_tti0", 2000)
Original comment by florentbr
on 28 Jul 2014 at 12:22
[deleted comment]
Hi Florent,
I have added both implicit and explicit wait but still getting the same issue.
Please see the code below:
Sub google()
Dim driver As New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.setImplicitWait (3000)
driver.get "/"
Set element = driver.findElementByXPath("//*[@id='gs_tti0']", 3000)
X = element.getAttribute("id")
If driver.isElementPresent("id=" & X) Then
Debug.Print ("Element found in run 1")
Else
Debug.Print ("element not found in run 1")
End If
driver.stop
driver.Start "firefox", "http://www.google.com"
driver.get "/"
Set element = driver.findElementByXPath("//*[@id='gs_tti0']", 3000)
X = element.getAttribute("id")
If driver.isElementPresent("id=" & X) Then
Debug.Print ("Element found in run 2")
Else
Debug.Print ("element not found in run 2")
End If
driver.stop
End Sub
Original comment by mohitmon...@gmail.com
on 30 Jul 2014 at 7:01
Original comment by florentbr
on 8 Sep 2014 at 5:40
Original issue reported on code.google.com by
mohitmon...@gmail.com
on 10 Jun 2014 at 7:32