Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with xpath #47

Closed
martinoclaudio opened this issue Dec 14, 2015 · 4 comments
Closed

problems with xpath #47

martinoclaudio opened this issue Dec 14, 2015 · 4 comments

Comments

@martinoclaudio
Copy link

Hello Florent,
I found a problem with the updated driver.
Below ist the code that worked with Release v2.0.5.0 but not with Release v2.0.6.0
The last instruction
driver.FindElementByXPath_("(//a@id='ctl00_ctl10_ProductOverviewTable_ProductGrid_DerivativeLever_desc'])[2]").Click
is not working with the new Version. Could you please check for this?

Here is the code:

#If VBA7 Then
    Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal ms As LongPtr)
#Else
    Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)
#End If



Public driver As New Selenium.FirefoxDriver
Public By As New By, Assert As New Selenium.Assert, Verify As New Selenium.Verify, Waiter As New Selenium.Waiter
Public Utils As New Selenium.Utils
Public keys As New Selenium.keys

Sub Test()
Dim Tempstr As String, helpstring As String
    driver.Start "firefox", "https://www.xmarkets.db.com/DE/Produkt_Uebersicht/WAVEs_XXL_Put"
    driver.Timeouts.ImplicitWait = 3000
    driver.Timeouts.Script = 3000
    driver.Timeouts.Server = 60000
    driver.Timeouts.PageLoad = 60000
    driver.Get "/"
    driver.FindElementById("ctl00_leftNavigation_ctl00_asidebar-tab-navigation_DerivativeFilter_DerivativeLever_rightAmount").Click
        helpstring = "document.getElementById('ctl00_leftNavigation_ctl00_asidebar-tab-navigation_DerivativeFilter_DerivativeLever_rightAmount').value='" & 20 & "'"
    driver.ExecuteScript (helpstring): Sleep 100

    driver.FindElementById("ctl00_leftNavigation_ctl00_asidebar-tab-navigation_DerivativeFilter_DerivativeLever_rightAmount").SendKeys (keys.Enter)
    Sleep 5000
    Tempstr = driver.FindElementByCss("span.title-sub.small").Text
    driver.FindElementByXPath("(//a[@id='ctl00_ctl10_ProductOverviewTable_ProductGrid_DerivativeLever_desc'])[2]").Click
End Sub
@florentbr
Copy link
Owner

The web page has two sort down arrows for the same purpose and you picked the wrong one to click on.
One is for the static header and the other one is for the floating header.
Set a breakpoint and evaluate the XPath in Firefox to see where the elements are once the page is s crolled:

$x("//a[@id='ctl00_ctl10_ProductOverviewTable_ProductGrid_DerivativeLever_desc']")

@martinoclaudio
Copy link
Author

Hello Florent,

Thanks again for your quick reply.

The problem I am currently facing is that there are quite a lot of instructions that worked with the old version but not now on different web pages.

I understand your explanation, but why did the loading behaviour of the webpage change dependent on the web driver and how could I avoid future headaches? Is there any safe way to prevent those issues for future updates?

If I reinstall the old version v2.0.5.0 all is running as always, but with the new version I am facing those issues.

I have installed:

Firefox 42.0

Excel 2010, completely updated

Windows 7 and Windows 8.1

Best regards

Martin

Von: Florent Breheret [mailto:notifications@github.com]
Gesendet: Montag, 14. Dezember 2015 16:59
An: florentbr/SeleniumBasic
Cc: martinoclaudio
Betreff: Re: [SeleniumBasic] problems with xpath (#47)

The web page has two sort down arrows for the same purpose and you picked the wrong one to click on.
One is for the static header and the other one is for the floating header.
Set a breakpoint and evaluate the XPath in Firefox to see where the elements are once the page is s crolled:

$x("//a[@id='ctl00_ctl10_ProductOverviewTable_ProductGrid_DerivativeLever_desc']")


Reply to this email directly or view it on GitHub #47 (comment) .Das Bild wurde vom Absender entfernt.

@florentbr
Copy link
Owner

I understand your explanation, but why did the loading behaviour of the webpage change dependent on the web driver and how could I avoid future headaches?

This change of behaviour in the Firefox driver was an attempt to make it interact more like a real user.
With the previous version you were able to click an element that wasn't visible to begin with.
The only issue I see here is that there should be an error telling that the element cannot be clicked.
Here is the issue in question raised in the Selenium project:
SeleniumHQ/selenium#1202

Is there any safe way to prevent those issues for future updates?
No

@martinoclaudio
Copy link
Author

Thanks a lot. It is very helpful understanding the background!

Von: Florent Breheret [mailto:notifications@github.com]
Gesendet: Montag, 14. Dezember 2015 19:12
An: florentbr/SeleniumBasic
Cc: martinoclaudio
Betreff: Re: [SeleniumBasic] problems with xpath (#47)

I understand your explanation, but why did the loading behaviour of the webpage change dependent on the web driver and how could I avoid future headaches?

This change of behaviour in the Firefox driver was an attempt to make it interact more like a real user.
With the previous version you were able to click an element that wasn't visible to begin with.
The only issue I see here is that there should be an error telling that the element cannot be clicked.
Here is the issue in question raised in the Selenium project:
SeleniumHQ/selenium#1202 SeleniumHQ/selenium#1202

Is there any safe way to prevent those issues for future updates?
No


Reply to this email directly or view it on GitHub #47 (comment) .Das Bild wurde vom Absender entfernt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants