Jump to content

I've not be able to get either the xpath, or css Selector path to work consistently with $_WD_LOCATOR_ByXPath


Recommended Posts

Hello,

I have an web page icon that needs to clicked on in order to turn on certain functionality on the page, however, I've not be able to get either the xpath, or css Selector path to work consistently with $_WD_LOCATOR_ByXPath; mostly the automation does not click on the icon.  Oddly enough, I am not having this issue w/ other objects on the page.  I'm wondering if this more of a Web Driver configuration issue, such as how I have $sDesiredCapabilities defined... this is not a public site; it's private and requires a username/password.  This is my code as of this point; I have comments related to the out-put pane feedback from each attempted $_WD_LOCATOR_ByXPath:

; Visibilty Page; Click Auto-refresh & the Forklift icon:
;;;;;;;;;;;;;;;;;;;;;;;;;;;
If WinActive("Visibility - Google Chrome","") Then
    ; MsgBox($MB_SYSTEMMODAL, "ACTIVATE", "Visibilty Page Active", 5)
    Sleep(4000)

    ; Click on the Vehicle icon
    ; Below code applys to the icon when it is not active:

    ; Previously worked, but no more.
    ; Output pane states__WD_Post ==> Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Cdiv class=\"icon VEHICLE-icon\">\u003C/div> is not clickable at point (1465, 831).
    Global $sVhlElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='icon VEHICLE-icon']")

    ;SelectorsHub xpath; output pane states  __WD_Post ==> Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Cdiv class=\"icon VEHICLE-icon\">\u003C/div> is not clickable at point (1481, 830).
    ; Global $sVhlElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@title='Show Vehicle']//div")

    ; tried using contains per "BigDaddyO" suggestion; output pane states nSyntaxError: Failed to execute.
    ; Global $sVhlElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains@class='leaflet-marker-pane']//div[22]) and contains (@title='Show Vehicle')")

    ; ChroPath xpath; output pane states Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted..."
    ; Global $sVhlElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//body/div[@id='app']/div[@id='container']/div[@id='main-map-wrapper']/div[@id='main-map']/div[2]/div[4]/div[3]/div[2]/div[1]")

    _WD_ElementAction($sSession, $sVhlElement, 'click'); Click Vehicle icon

 

Can anyone explain what is meant by " __WD_Post ==> Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Cdiv class=\"icon VEHICLE-icon\">\u003C/div> is not clickable at point (1465, 831)..."?  This is the output from the SciTE out-put pane.

I can provide screen shots of inspecting via ChroPath and SelectorsHub is need be.

 

Link to post
Share on other sites
1 hour ago, Dmp said:

If WinActive("Visibility - Google Chrome","") Then

Not sure if this is part of your problem, but what happens when Chrome isn't the topmost window? This entire section of code will be skipped, right?

Quote

Can anyone explain what is meant by " __WD_Post ==> Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Cdiv class=\"icon VEHICLE-icon\">\u003C/div> is not clickable at point (1465, 831)

Best guess would be that the element is partially hidden by another element. Are you sure that the Div element is the correct element to be clicked?

Quote

I've not be able to get either the xpath, or css Selector path to work consistently with $_WD_LOCATOR_ByXPath

I assume that you didn't actually try to use a CSS selector with $_WD_LOCATOR_ByXPath, correct? 😉

Link to post
Share on other sites

 

2 hours ago, Dmp said:

div> is not clickable at point (1465, 831

1.
Headless mode ?

 

2.

Element can be hidden, inactive etc...
so try to use

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='icon VEHICLE-icon']",Default,Default, BitOR($_WD_OPTION_Visible, $_WD_OPTION_Enabled))

instead

_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='icon VEHICLE-icon']")

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites

Thank you both for your feedback... has been informative and helpful.

I removed the If WinActive condition for the Visibility page, but it did not appear to make a difference; still had the "element click intercepted","message..."

I did try CSS selector with $_WD_LOCATOR_ByXPath from SlectoresHub; the ChroPath values were of no use. Interestingly, both the SelectorsHub values end w/ "...div" undefined. I have attached an image of the output from inspecting the icon.

I implemented MPVs's  proposed: _WD_WaitElement and changed the order of the icons being clicked, which may have had something to do w/ Danp2's comment "Best guess would be that the element is partially hidden by another element."  As a result, the icon is now responding to the click action command.

I still feel that I need to take a more robust measure to address this issue; I'm wondering if my definition for  $sDesiredCapabilities is insufficient:

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"], "excludeSwitches": [ "enable-automation"]}}}}'

I also tried:

sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'

 

Link to post
Share on other sites
2 hours ago, Danp2 said:

I doubt that changing your Capabilities string will help with this.

It may vary... it depends on browser and if he use Headless or not.
This is something similar that I ask you few days ago (maybe even few weeks ago).

@Dmp give it a try with this following SetupChrome function:

Func _MY__WD_SetupChrome($b_Headless = False, $s_Download_dir = '', $_WD_DEBUG_LEVEL = Default, $s_Log_FileFullPath = Null)
    If $_WD_DEBUG_LEVEL = Default Then
        $_WD_DEBUG = $_WD_DEBUG_Error
        If Not @Compiled Then $_WD_DEBUG = $_WD_DEBUG_Info
    EndIf

    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)

    #  !!! WARRNING !!!   AS DEFAULT DO NOT USE '--log-path=' BECAUSE OF   GDPR / RODO law rules
    If $s_Log_FileFullPath = Default Then
        Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' WebDriver - Chrome - Testing.log'
        _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"')
    EndIf

    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)

    _WD_CapabilitiesAdd('firstMatch', 'chrome')
    _WD_CapabilitiesAdd('browserName', 'chrome')
    _WD_CapabilitiesAdd('w3c', True)
    _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default')
    _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' & _WD_GetBrowserVersion('chrome') & ' Safari/537.36')
    _WD_CapabilitiesAdd('args', '--profile-directory', Default)
    _WD_CapabilitiesAdd('args', 'start-maximized')
    _WD_CapabilitiesAdd('args', 'disable-infobars')
    _WD_CapabilitiesAdd('args', '--no-sandbox')
    _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled')
    _WD_CapabilitiesAdd('args', '--disable-web-security')
    _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220
    _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220
    If $b_Headless Then _
            _WD_CapabilitiesAdd('args', '--headless')
    If $s_Download_dir Then _
            _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir)
    _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    _WD_CapabilitiesAdd('excludeSwitches', 'load-extension')

    _WD_CapabilitiesDump(@ScriptLineNumber & ' TESTING')
    Local $s_Capabilities = _WD_CapabilitiesGet()

    Local $WD_SESSION = __MY__WD_Startup($s_Capabilities)
    Return SetError(@error, @extended, $WD_SESSION)
EndFunc   ;==>_MY__WD_SetupChrome

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites

btw.
take a look also here:


It can be possible that you have an issue with ZOOM ratio, so try to use :
 

Func _WD_GetDevicePixelRatio($sSession)
    Local Const $sFuncName = "_WD_devicePixelRatio"
    Local $sResponse = _WD_ExecuteScript($sSession, "return window.devicePixelRatio", Default, Default)
    If @error <> $_WD_ERROR_Success Then _
            Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception), "")

    Local $oJSON = Json_Decode($sResponse)
    Local $iResult = Json_Get($oJSON, "[value]")
    Return SetError($_WD_ERROR_Success, 0, $iResult)
EndFunc   ;==>_WD_GetDevicePixelRatio

if it is = 1 or not .


 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-10-18

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...