Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

1 hour ago, Danp2 said:

Provide more details so that we can better know how to assist you. Show us the contents of your spreadsheet. Give more details on the data you want to retrieve from the website, etc.

Sorry to double post. Nothing special in spreadsheet, that's why I try to avoid learning OOCalc functions, just manual copypaste stuff. I have main table and need data in "row" format in it. 

1) Take links list https://i.imgur.com/RWonMQD.png (loop them with simple move down one row for manual/user imitation script)

2) Paste copied data to converter https://i.imgur.com/tcIygay.png (get my desired "row")

3) Than I have table with rows of data that I can sort etc.

Example of page

That's it. Everything I need from excel/LibreCalc is go to page, copy cell, go to cell adress, paste, copy row, paste it on another page, move spreadsheet down one row. Nothing fancy.

Link to comment
Share on other sites

15 minutes ago, grablestyp said:

Tried that method but it didn't work for me, had to close browser and give script a fresh start for it to work.

Sorry, but "didn't work" isn't going to cut it if you really want help. Show us your code and the resulting output of running it in Scite.

Note: This will only work with an marionette enabled instance of Firefox. You either have to

  • launched Firefiox with the --marionette option, or
  • go to About:Config page and change "marionette.enabled" to true (untested)

P.S. I use this method daily to interact with an existing Firefox instance.

Link to comment
Share on other sites

7 minutes ago, Danp2 said:

Sorry, but "didn't work" isn't going to cut it if you really want help.

Problem in Chrome was user directory is already is use. So when I gave it fresh starts it started working and I moved on. Sorry if that's bad feedback, just wasn't the issue anymore.

Can you clarify 2) and 3) for me and stop wasting time with my troubles? These "not gonna cut it" or "what exactly???" responses lead nowhere as much as unclear help requests.

If I could explain better or do it all myself, I would.  Not looking to become an expert, just want to solve this ASAP and move on. 

Link to comment
Share on other sites

I will try to explain, what i want to do is to never execute the element action until the element is already found and know for my script 
 

Do
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath, "", $generalTimeout)
$fElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath)
Call("SOSExit","5")
Until @error = $_WD_ERROR_SUCCESS
_WD_ElementAction($sSession, $fElement, 'click')
Sleep(500)

For sure you can understand this piece of code

I do not want to click on this element unless it's already succeed in finding it, in this code, sometimes if its timeout, the web driver move to the next code instructions written as its already (Succeed) but this is not correct. it failed and the log shows that there is a timeout but it returned _WD_ERROR_SUCCESS which i do not understand why.

So am thinking to detect either if its returned timeout or not and if it return i will exit my script. 

 

Link to comment
Share on other sites

Your code won't work as written because the value of @error gets reset when you execute the Call function. You would need to save it's value and then check against the variable instead of @error, like this --

Do
    _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath, "", $generalTimeout)
    $fElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath)
    $iResult = @error
    Call("SOSExit","5")
Until $iResult = $_WD_ERROR_SUCCESS

_WD_ElementAction($sSession, $fElement, 'click')
Sleep(500)

You could also optimize this by moving the call to _WD_FindElement outside of the loop because it will always fail until _WD_WaitElement is successful. So the new version would look like this --

Do
    _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath, "", $generalTimeout)
    $iResult = @error
    Call("SOSExit","5")
Until $iResult = $_WD_ERROR_SUCCESS

$fElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $FelementPath)
_WD_ElementAction($sSession, $fElement, 'click')
Sleep(500)

You didn't explain the call to SOSExit, so you may want / need to move it also. You could also add additional error checking after the call to _WD_FindElement.

Note: As written, your script will hang and never continue if the element never appears. You should consider adjusting the code so that it exits after a given number of attempts.

Link to comment
Share on other sites

You were right, i just noticed that 1 minutes before you wrote your comment, that (@error) will resets cause i put it after the _WD_FindElement. so it will give me uncertain status.

Regarding SOSExit, its the number of attempts you were talking about. 

Thank you @Danp2 for being there all the time :)

Link to comment
Share on other sites

@Danp2 Another question please, it may not relate to Web Driver UDF directly but i believe its the best place to mention it.

When i convert my script to .Exe file, and execute it, it works well and done what it supposed to do but, in case of slow internet connections the function (_WD_Attach("URL") sometimes it through an error (General Error) if i click ok the script will proceed normally doing its job.

I wonder how i can catch this kind of error to disable it? like i do not want any advanced errors appear to the script users, i want only to disable it, any advice? 

Link to comment
Share on other sites

@Retaki _WD_Attach doesn't perform any internet activities, so I don't see how a slow internet connection could be the issue here. Looking at the code, this error will only occur when the following line from _WD_Attach returns an error --

$aHandles = _WD_Window($sSession, 'handles')

So why does it fail and what is the actual error code being returned by this function call? It would be great if you could come up with a way to reliably reproduce this error.

You can eliminate the popup messagebox by either of the following methods --

  • Set $_WD_DEBUG to $_WD_DEBUG_None
  • Set $_WD_ERROR_MSGBOX equal to False
Link to comment
Share on other sites

_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.6
_WDStartup: WinHTTP:    1.6.4.2
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="Z:\xxx\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"80.0.3987.149","chrome":{"chromedriverVersion":"80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})","userDataDir":"C:\\Users\\Xxxx\\AppData\\Local\\Temp\\scoped_dir16292_1169614922"},"goog:chromeOptions":{"debuggerAddress":"localhost:56365"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"c25209b1b78f003b92ffcfc8ec7d0520"}}
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"80.0.3987.149","chrome":{"chromedriverVersion":"80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})","userDataDir":"C:\\Users\\Xxx\\AppData\\Local\\Temp\\scoped_dir16292_1169614922"},"goog:chromeOptions":{"debuggerAddress":"localhost:56365"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"c25209b1b78f003b92ffcfc8ec7d0520"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/c25209b1b78f003b92ffcfc8ec7d0520/url; $sData={"url":"http://Xxxx.xxxx"}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_Navigate: 0
_WD_Navigate ==> Send / Recv error: HTTP status = 0
__WD_Get: URL=HTTP://127.0.0.1:9515/session/c25209b1b78f003b92ffcfc8ec7d0520/url
__WD_Get: StatusCode=0; $iResult = 6; $sResponseText=0...
__WD_Get ==> Send / Recv error
_WD_Action: 0
_WD_Action ==> Webdriver Exception: HTTP status = 0
URL=
Session=c25209b1b78f003b92ffcfc8ec7d0520
__WD_Get: URL=HTTP://127.0.0.1:9515/session/c25209b1b78f003b92ffcfc8ec7d0520/window/handles
__WD_Get: StatusCode=0; $iResult = 6; $sResponseText=0...
__WD_Get ==> Send / Recv error
_WD_Window: 0...
_WD_Window ==> Webdriver Exception: HTTP status = 0
_WD_Attach ==> General Error
__WD_Get: URL=HTTP://127.0.0.1:9515/session/c25209b1b78f003b92ffcfc8ec7d0520/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["CDwindow-77E490297197E27110C6473DEF7EC012"]}...
_WD_Window: {"value":["CDwindow-77E490297197E27110C6473DEF7EC012"]}...

If you do not mind, here is my log. As you can notice the _WD_Attach ==> through a general error which execute the popup 

Link to comment
Share on other sites

All of your low level commands (__WD_Post & __WD_Get) are failing. Therefore, all of your calls to the UDF functions are failing as well.

You need to figure out why these are failing. Your responses should look more like this --

__WD_Post: URL=HTTP://127.0.0.1:4444/session/67b820f3-0697-47fb-b4bc-e3c7cd04ff5f/url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:4444/session/67b820f3-0697-47fb-b4bc-e3c7cd04ff5f/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["19"]}...
_WD_Window: {"value":["19"]}...
__WD_Get: URL=HTTP://127.0.0.1:4444/session/67b820f3-0697-47fb-b4bc-e3c7cd04ff5f/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"19"}...
_WD_Window: {"value":"19"}...

Note the statuscode of 200 vs yours of 0.

Link to comment
Share on other sites

_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.6
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="xx\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"80.0.3987.149","chrome":{"chromedriverVersion":"80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})","userDataDir":"C:\\Users\\xx\\AppData\\Local\\Temp\\scoped_dir6652_312627547"},"goog:chromeOptions":{"debuggerAddress":"localhost:58771"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"1d6675e8087766fa2ec8e59016adde91"}}
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"80.0.3987.149","chrome":{"chromedriverVersion":"80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})","userDataDir":"C:\\Users\\xx\\AppData\\Local\\Temp\\scoped_dir6652_312627547"},"goog:chromeOptions":{"debuggerAddress":"localhost:58771"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"1d6675e8087766fa2ec8e59016adde91"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/url; $sData={"url":"http://xx.xx"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://xx.xx/"}...
_WD_Action: {"value":"https://xx.xx/"}
URL=https://xx.xx/
Session=1d6675e8087766fa2ec8e59016adde91
__WD_Get: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["CDwindow-C7EAE0E8D75F65AAE2F8B8E846CC3D46"]}...
_WD_Window: {"value":["CDwindow-C7EAE0E8D75F65AAE2F8B8E846CC3D46"]}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-C7EAE0E8D75F65AAE2F8B8E846CC3D46"}...
_WD_Window: {"value":"CDwindow-C7EAE0E8D75F65AAE2F8B8E846CC3D46"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/window; $sData={"handle":"CDwindow-C7EAE0E8D75F65AAE2F8B8E846CC3D46"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://xx.xx/"}...
_WD_Action: {"value":"https://xx.xx/"}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/element; $sData={"using":"xpath","value":"//input[@name='username']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"ca9f06e5-27f1-4c75-b97f-dcc944ce3ebc"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"ca9f06e5-27f1-4c75-b97f-dcc944ce3ebc"}}
_WD_WaitElement ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session/1d6675e8087766fa2ec8e59016adde91/element; $sData={"using":"xpath","value":"//input[@name='username']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"ca9f06e5-27f1-4c75-b97f-dcc944ce3ebc"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"ca9f06e5-27f1-4c75-b97f-dcc944ce3ebc"}}

 

Seems like you were right, i was using an older version of WinHTTP, after installing the latest one, it works with status code = 200 and there is no any msgbox any more. 

Anyway i disabled the debug thing, thank you sir.  @Danp2

Link to comment
Share on other sites

The latest version on Github (not an official release, but the latest source) is 1.6.4.2, which is what your earlier post showed. Now it shows you are running 1.6.4.1. 😕

There are some important changes between these two versions, so you are likely to run into additional problems unless you update to v1.6.4.2.

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...