Jump to content

WebDriver UDF - Help & Support


Recommended Posts

1 hour ago, _leo_ said:

I figured out that this is caused by "user-data-dir=userData", since it doesnt happen if I delete this part. Does anyone have an idea on how to have all the user data without the url bar getting highlighted?

The behavior doesn't occur on the initial run (userData directory is empty or non-existent). There's something in this custom profile that is causing this to occur.

Let us know if you are able to figure out the cause.

Link to comment
Share on other sites

 _WD_FrameEnter($sSession, $sIndexOrID) . Pls , help me !! How to find $sIndexOrID ??? i try 

$eFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@name='QC Test Máy']")
ConsoleWrite(@CRLF & "Finding Frame result (" & $eFrame & ")" & @CRLF & @CRLF)

$ID = _WD_ElementAction($sSession, $eFrame, 'attribute', 'id')                          ;Get the @id to pass into the _WD_FrameEnter
ConsoleWrite(@CRLF & "Finding The Frame id result (" & $ID & ")" & @CRLF & @CRLF)

$sFrame = _WD_FrameEnter($sSession, $ID)
ConsoleWrite(@CRLF & "Enter Frame result (" & $sFrame & ")" & @CRLF & @CRLF)

My console 

__WD_Post: URL=HTTP://127.0.0.1:9515/session/b523fdcbaccef2017a2159c9fcd56888/element; $sData={"using":"xpath","value":"//iframe[@name='QC Test Mṧ]"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"62adf288-6d53-44b1-a18b-80bf42c53165"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"62adf288-6d53-44b1-a18b-80bf42c53165"}}

Finding Frame result (62adf288-6d53-44b1-a18b-80bf42c53165)

__WD_Get: URL=HTTP://127.0.0.1:9515/session/b523fdcbaccef2017a2159c9fcd56888/element/62adf288-6d53-44b1-a18b-80bf42c53165/attribute/id
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":""}...
_WD_ElementAction: {"value":""}...

Finding The Frame id result ()

__WD_Post: URL=HTTP://127.0.0.1:9515/session/b523fdcbaccef2017a2159c9fcd56888/frame; $sData={"id":{"element-6066-11e4-a52e-4f735466cecf":""}}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"stale element reference","message":"element is not attached to the page document(Session infochrome=75.0.3770.142)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00B73CF0+867568]\n\tOrdinal0 [0x00B1DB7D+514941]\n\tOrdinal0 [0x00AEB367+308071]\n\tOrdinal0 [0x00AECF2A+315178]\n\tOrdinal0 [0x00AECE14+314900]\n\tOrdinal0 [0x00AB9FDC+106460]\n\tOrdinal0 [0x00AD333E+209726]\n\tOrdinal0 [0x00ACAE8D+175757]\n\tOrdinal0 [0x00AD278D+206733]\n\tOrdinal0 [0x00ACAD2B+175403]\n\tOrdinal0 [0x00AB3740+79680]\n\tOrdinal0 [0x00AB4CFC+85244]\n\tOrdinal0 [0x00AB4C50+85072]\n\tOrdinal0 [0x00B7E62A+910890]\n\tOrdinal0 [0x00B28993+559507]\n\tOrdinal0 [0x00B28BA3+560035]\n\tOrdinal0 [0x00B28C8C+560268]\n\tOrdinal0 [0x00B81907+923911]\n\tOrdinal0 [0x00B287FF+559103]\n\tOrdinal0 [0x00B3306E+602222]\n\tOrdinal0 [0x00B3EA3B+649787]\n\tOrdinal0 [0x00B3EBA5+650149]\n\tOrdinal0 [0x00B3DDA5+646565]\n\tBaseThreadInitThunk [0x769B0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x76F3662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x76F365FD+189]\n"}}
_WD_Window: {"value":{"error":"stale element reference","message":"element is not attached to the page document(...
_WD_Window ==> Webdriver Exception: HTTP status = 404

Enter Frame result ()

Why id is "null" ?? Thank you so much !

Link to comment
Share on other sites

@TungNhoc, isn't $eFrame itself the ID of iframe element? Maybe you can do away with the 3rd and 4th lines of your code.

$eFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@name='QC Test Máy']")
ConsoleWrite(@CRLF & "Finding Frame ID (" & $eFrame & ")" & @CRLF & @CRLF)

$sFrame = _WD_FrameEnter($sSession, $eFrame)
ConsoleWrite(@CRLF & "Enter Frame result (" & $sFrame & ")" & @CRLF & @CRLF)

By the way, _WD_FrameEnter returns a boolean value.

Edited by CYCho
Link to comment
Share on other sites

Hey there!

I have a question: Is it possible to give no timeout for _WD_WaitElement, so that is waits until the element is found, even if it takes several minutes? This would be very useful because some elements on the websites are loading for aaaaagggeesss.😄

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $sStrategy, 0, 100000)

I have this code segment, but it is set to a time, not limitless. Thanks for advice!

Link to comment
Share on other sites

38 minutes ago, _leo_ said:

I have a question: Is it possible to give no timeout for _WD_WaitElement, so that is waits until the element is found, even if it takes several minutes?

I wouldn't recommend this as your script would never move beyond this line if the element isn't ever located. You have a couple of options --

  • Use the $iDelay parameter to specify an initial delay before the function begins looking for the element
  • You should be able to specify a value for $iTimeout that is large enough to allow the website to finish loading. For example, use a value of 300000 to wait up to 5 minutes
Link to comment
Share on other sites

Hi again 👋

I have to click button, but it is "clickable" only when i scroll down a website ( when I see that button on screen ). Is there any way to simulate that focus? I tried 

_WD_ElementAction($sSession, $sElement, $sCommand, 'active')

but it's not working :/

Link to comment
Share on other sites

Quick question, I am just starting out with using the WebDriver UDF, I saw somewhere while reading through the forums, that it is possible to change the default location of chrome. I just don't know where I would change it. For example, I am using chrome portable from a unc path. I know that the best scenario would be to install chrome the normal way but we cant here. I need a way to use Chrome for my project without installing it on the local PC. I have been searching the forums (And google with no luck), but if I messed it my apologies up front.

Link to comment
Share on other sites

38 minutes ago, P00PDOG said:

Quick question, I am just starting out with using the WebDriver UDF, I saw somewhere while reading through the forums, that it is possible to change the default location of chrome. I just don't know where I would change it. For example, I am using chrome portable from a unc path. I know that the best scenario would be to install chrome the normal way but we cant here. I need a way to use Chrome for my project without installing it on the local PC. I have been searching the forums (And google with no luck), but if I messed it my apologies up front.

I found it, It was just a few more searches. If anyone was interested in the answer...

https://sites.google.com/a/chromium.org/chromedriver/capabilities

image.png.9277b8c47efeebf8ca248082c819f1c6.png

Link to comment
Share on other sites

2 hours ago, P00PDOG said:

I found it, It was just a few more searches. If anyone was interested in the answer...

https://sites.google.com/a/chromium.org/chromedriver/capabilities

image.png.9277b8c47efeebf8ca248082c819f1c6.png

I fond one person who seemed to get this working, I think I'm close but may be missing something. I grabbed the driver for my version (75) only difference is I'm using the portable version. See my example below but browser does not open. I am guessing I am not using the correct syntax or something.
 

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=userData", "binary_location":"C:\\Users\\user1\\Desktop\\AutoLogontestCrome\\GoogleChromePortable.exe"] }}}}'
_WD_Startup()
Local $sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://google.com")
_WD_Shutdown()

 

Link to comment
Share on other sites

4 hours ago, CYCho said:

@P00PDOG I am unable to test your code in full, but one thing I can say is the syntax of "args" option. "binary=C:\Program Files\..." works for me.

thanks for the response. I made the change you recommended but it still doesn't run the portable exe... I changed the path to make it shorter...

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=userData", "binary=C:\AutoLogontestCrome\GoogleChromePortable.exe"] }}}}'

here is the output I get, the second error has to do with the website i think the first error has to do with the above...

_WDStartup: OS:    WIN_10 WIN32_NT 16299
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.1.0.20
_WDStartup: Driver:    chromedriver.exe
_WDStartup: Params:    --log-path=C:\AutoLogontestCrome\chrome.log
_WDStartup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=userData", "binary=C:\AutoLogontestCrome\GoogleChromePortable.exe"] }}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC2293+467603]\n\tOrdinal0 [0x00F75B4A+154442]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC2293+467603]\n\tOrdinal0 [0x00F75B4A+154442]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: missing command parameters
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"URL REMOVED"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC213C+467260]\n\tOrdinal0 [0x00F60569+66921]\n\tOrdinal0 [0x00F770C7+159943]\n\tOrdinal0 [0x00F75C40+154688]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC213C+467260]\n\tOrdinal0 [0x00F60569+66921]\n\tOrdinal0 [0x00F770C7+159943]\n\tOrdinal0 [0x00F75C40+154688]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}

 

 

Link to comment
Share on other sites

Regarding  the argument "user-data-dir=userData", is "userData" literally "userData" or a directory path for the Chrome user data, something like "C:\Users\User1\AppData\Local\Google\Chrome\User Data\Default"? You may find some suggestions in this forum for user-data-dir argument, but I  myself haven't been able to make use of it. Why don't you try the code with this argument removed? If it works, then you can move on to including the user data argument.

Link to comment
Share on other sites

That was just there from someone's example. I removed it but still the same thing.

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["binary=C:\AutoLogontestCrome\GoogleChromePortable.exe"] }}}}'

output

__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["binary=C:\AutoLogontestCrome\GoogleChromePortable.exe"] }}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC2293+467603]\n\tOrdinal0 [0x00F75B4A+154442]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010B1B43+1448771]\n\tOrdinal0 [0x01035A31+940593]\n\tOrdinal0 [0x00FC2293+467603]\n\tOrdinal0 [0x00F75B4A+154442]\n\tOrdinal0 [0x00F75818+153624]\n\tOrdinal0 [0x00F521FE+8702]\n\tOrdinal0 [0x00F52616+9750]\n\tOrdinal0 [0x00F52C00+11264]\n\tGetHandleVerifier [0x011F2E8C+1172172]\n\tGetHandleVerifier [0x0114FE55+504469]\n\tGetHandleVerifier [0x0114FBF0+503856]\n\tOrdinal0 [0x010BC9C8+1493448]\n\tGetHandleVerifier [0x0115062A+506474]\n\tOrdinal0 [0x01047156+1012054]\n\tOrdinal0 [0x01046FCF+1011663]\n\tOrdinal0 [0x00F5203A+8250]\n\tOrdinal0 [0x00F51D62+7522]\n\tGetHandleVerifier [0x0147D6AC+3836652]\n\tBaseThreadInitThunk [0x74338654+36]\n\tRtlGetAppContainerNamedObjectPath [0x77774A47+311]\n\tRtlGetAppContainerNamedObjectPath [0x77774A17+263]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: missing command parameters

Link to comment
Share on other sites

23 minutes ago, CYCho said:

Regarding  the argument "user-data-dir=userData", is "userData" literally "userData" or a directory path for the Chrome user data, something like "C:\Users\User1\AppData\Local\Google\Chrome\User Data\Default"? You may find some suggestions in this forum for user-data-dir argument, but I  myself haven't been able to make use of it. Why don't you try the code with this argument removed? If it works, then you can move on to including the user data argument.

I think I'm going to try Iua instead, I am just doing a simple login script (not really a testing script) and I am over thinking it. Thanks for your help though. Cheers!

Link to comment
Share on other sites

I am also in process of learning webdriver functions. Once I experienced a similar situation when there was mismatch of Chrome and ChromeDiver versions. You may want to look at http://chromedriver.chromium.org/downloads and check your versions. @Danp2 or other experts may be able to give you a better suggestion.

Link to comment
Share on other sites

On 7/29/2019 at 1:47 PM, Danpol said:

_WD_ElementAction($sSession, $sElement, $sCommand, 'active')

This actually returns the id for the currently active element (the $sElement parameter is unused in this instance).

According to the W3C specs, the element's container should automatically be scrolled into view. Can you provide an example where this doesn't occur?

Edit: You may also want to search this thread for the phrase "ScrollIntoView"

Edited by Danp2
Link to comment
Share on other sites

Hey guys!

I am trying to get the innertext of an element and save it as variable.  To achieve that, I am using the ClipGet Function. The innertext of the element is changing frequetly, therefore I can't use it as a constant in my script. 

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//strong[@class='footer-name text-truncate']", 0, $iPause*30, True)
   $ogetname = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//strong[@class='footer-name text-truncate']")

   $oResult = _WD_ElementAction($sSession, $ogetname, 'Attribute', 'text')
   MsgBox(0, "Show Result", $oResult)
   _ArrayDisplay($oResult) ;I was not sure if this would return an array or a string.
   Global $sGanzerName = ClipGet()

The message box did not return anything, ArrayDisplay only weird Numbers. 

Since I was not sure, if this is possible with the webdriver functions, I tried it with this:

$var1 = _WD_ExecuteScript($sSession, 'return $sSession.findElement(By.class("footer-name text-truncate")).getText()')
   MsgBox(0, "Result", $var1)

Both without sucess. I appreciate any help😊

Forum.PNG.52cc410e7a570d71e61de63911acc7b6.PNG Just for additional clearace: In this case, I would like to get the "15D" stored as a variable.

Link to comment
Share on other sites

@_leo_ You should check the value of @error following the call the the webdriver functions. I suspect that the element isn't being found because there are multiple classes involved. You would need to switch to using the Contains function for each class or maybe switching to using CSS for the selector instead of xpath.

Also, you should watch the results that appear in the Scite output panel and use that as a way to screen your scripts success or failure when executing the webdriver functions.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...