Jump to content

WebDriver UDF - Help & Support


Recommended Posts

6 hours ago, Danp2 said:

@dumdumpop A few different options here --

  1. Use _WD_ElementAction to retrieve the text after you've located the Select element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id=DropDown]")
    $sText = _WD_ElementAction($sSession, $sElement, 'text')

     

  2. You could also try calling _WD_FindElement twice, where you pass the result from the first call into the second one --
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id=DropDown]")
    $sElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//option", $sElement, True)

     

AFAIK, you should be able to use _WD_ExecuteScript to call just about any command or function that you desire. Can you provide a runnable snippet of code that demonstrates where the jQuery interaction was unsuccessful?
 

I just got the JQuery to work! This is absolutely incredible thank you!
*EDIT
I did notice one thing, when I try to retrieve a value, it comes back as null.  Is there a way to retrieve information from a JQuery script call?
ex: using a script like $('#ElementId').height()
I know I can probably get the information from the FindElement function, but just exploring possibilities right now :) 

Also both of what you sent ended up working perfectly, thank you so much!

6 hours ago, Danyfirex said:

Hello. You also could do this.

Local $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='DropDown']/option","",True)
;~ _ArrayDisplay($aElements)
For $i=0 to UBound($aElements)-1
    ConsoleWrite(_WD_ElementAction($sSession, $aElements[$i], 'text') & @CRLF)
    ConsoleWrite(_WD_ElementAction($sSession,$aElements[$i], 'attribute', 'value') & @CRLF)
Next

Saludos

This was exactly what I was hoping to get out of this too, thank you so much!

Edited by dumdumpop
Link to post
Share on other sites
  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is the "General Help and Support" thread for the WebDriver UDF. The UDF itself can be downloaded here. So if you have any questions, suggestions or errors please post here.

Hello @GregEisenberg You need to do this: Local $oJsonRect=_WD_ElementAction($sSession, $sElements, 'rect') ConsoleWrite("!" & Json_Get($oJsonRect, "[x]") & @CRLF) ConsoleWr

Time ago I wrote a function to extract data from  the source HTML code of tables. https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/ Seems that that fun

Posted Images

8 hours ago, dumdumpop said:

I did notice one thing, when I try to retrieve a value, it comes back as null.  Is there a way to retrieve information from a JQuery script call?
ex: using a script like $('#ElementId').height()

Did you forget to return the value?

_WD_ExecuteScript($sSession, "return $('#ElementId').height()")

 

Link to post
Share on other sites
9 minutes ago, Danp2 said:

Did you forget to return the value?

_WD_ExecuteScript($sSession, "return $('#ElementId').height()")

 

A bit of a face-palm moment.  I didn't return it, just tested the return and works like a charm. Lol thanks again!

Link to post
Share on other sites

Howdy,

  This is probably a simple question.  I'm using this great UDF with FireFox.  I have a 'main' window setup without any problems.  My question is how can I get a 'new tab' windows opened up properly?  When I attempt to do so the new tab itself opens without any problem...however I cannot get it to navigate to a URL...?

 

Global Const $_TestType = $eFireFox
Global $sDesiredCapabilities
Global $iIndex
Global $sSession
Global $sElement

$_WD_DEBUG = True

 Switch $_TestType
     Case $eFireFox
         SetupGecko()
        
     Case $eChrome
         SetupChrome()
  
 EndSwitch
 
 _WD_Startup()
 
 $sSession = _WD_CreateSession($sDesiredCapabilities)
 
 $oIE2 = _WD_Navigate($sSession, "https://www.google.com")
 
 ;;;;;ABOVE ALL WORKS FINE...I TRY TO CREATE A NEW 'TAB'...
 
 Local $_URL_TAB = _WD_NewTab($sSession, False)  ;opens a new tab no problem
 _WD_Navigate($_URL_TAB, "http://www.nfl.com")  ;new tab does not navigate anywhere...?

  I get an "invalid session id" error...?  

I was under the impression that the '_WD_NewTab' creates a handle to be used to control the navigation in the new tab...what am I not understanding here?  Thanks in advance for any advice.  Regards.

 

Edited by Burgs
Link to post
Share on other sites

You need to switch to the tab(window) so just set the switch parameter to true in NewTab Function. 

 

Local $hNewTabWindow = _WD_NewTab($sSession, True)
ConsoleWrite($hNewTabWindow & @CRLF)
_WD_Navigate($sSession, "https://www.google.com")

 

Saludos

Link to post
Share on other sites
6 hours ago, Burgs said:

I was under the impression that the '_WD_NewTab' creates a handle to be used to control the navigation in the new tab...what am I not understanding here?  Thanks in advance for any advice.  Regards.

The handle returned by _WD_NewTab is not a session ID, so it can't be used in that manner. Either change the $iSwitch parameter to True as shown above or you can manually switch to any tab like this --

_WD_Window($sSession, 'Switch', '{"handle":"' & $YOUR_TAB_HANDLE_GOES_HERE & '"}')

 

Link to post
Share on other sites

Hello

Chrome web driver closes after ruuning wd_test.au3

  • Win10 Home x64 
  • Chrome 67.0.3396.99 x64
  • chromedriver.exe v2.40 x32 (latest)
  • autoit 3.3.14.5

Console otput:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\_Projects\ltb\wd_test.au3"    
_WDStartup: OS:    WIN_10 WIN32_NT 17134 
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.1.0.10
_WDStartup: Driver:    chromedriver.exe
_WDStartup: Params:    --log-path="C:\_Projects\at\chrome.log"
_WDStartup: Port:    9515
_WD_Startup ==> General Error: Error launching web driver!
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_CreateSession: 0
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
Bypass: TestTimeouts
Bypass: TestNavigation
Bypass: TestElements
Bypass: TestScript
Bypass: TestCookies
Bypass: TestAlerts
Running: TestFrames
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_frame_cols"}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_Navigate: 0
_WD_Navigate ==> Webdriver Exception: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//execute/sync; $sData={"script":"return window.frames.length", "args":[[]]}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_ExecuteScript: 0
Frames=0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//execute/sync; $sData={"script":"return window.top == window.self", "args":[[]]}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_ExecuteScript: 0
TopWindow=
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//iframe[@id='iframeResult']"}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_FindElement: 0
_WD_FindElement ==> Send / Recv error: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//frame; $sData={"id":{"element-6066-11e4-a52e-4f735466cecf":""}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_Window: 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//execute/sync; $sData={"script":"return window.top == window.self", "args":[[]]}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_ExecuteScript: 0
TopWindow=
__WD_Post: URL=HTTP://127.0.0.1:9515/session//frame/parent; $sData={}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_Window: 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//execute/sync; $sData={"script":"return window.top == window.self", "args":[[]]}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_ExecuteScript: 0
TopWindow=
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/
__WD_Delete: StatusCode=0; ResponseText=0
__WD_Delete ==> Webdriver Exception
_WD_DeleteSession: 0
_WD_DeleteSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 13.46

Link to post
Share on other sites

Danp2, Hello again!

I figured out how to search for items with id, for example, entering data into the search window and pressing a button. But I still did not understand how to search for the elements as described below.

How to find element by its text, for ex: Gmail Mail button.
image.thumb.png.f1853ec130c2cb945e12533d39470287.png

Link to post
Share on other sites

Hello @slvtn666 You can do this:

 

local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[contains(text(),'hereyourtext')]")

Saludos

Link to post
Share on other sites
3 minutes ago, Danyfirex said:

Hello @slvtn666 You can do this:

 

local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[contains(text(),'hereyourtext')]")

Saludos

Thank you for your reply

Im getting following error:

__WD_Post: URL=HTTP://127.0.0.1:9515/session/aefbbec49c57a7d1e651158e92175521/element; $sData={"using":"xpath","value":"//*[contains(text(),'��)]"}
__WD_Post: StatusCode=400; ResponseText=missing command parameters
_WD_FindElement: missing command parameters
_WD_FindElement ==> Webdriver Exception: HTTP status = 400

Link to post
Share on other sites

You need to add the last single quoted after the search  text.

 

 

Saludos

Link to post
Share on other sites

Thank for udf

I have simple code here: 

#include "wd_core.au3"
    
Local $url = "http://google.com/"
Local $sDesiredCapabilities
SetupChrome()
_WD_Startup()
$Session = _WD_CreateSession($sDesiredCapabilities)
Sleep(2000)
_WD_Navigate($Session, $url)
    _WD_Shutdown()
    
Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')
        $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}'
EndFunc

When I run this code, New profile chrome open. So I can't see account gmail and browser history. But I want keep it. How can i do this? Thank you ..

 

Link to post
Share on other sites

Hello

  Sorry I need a clarification to my above post.  I was able to create new 'tab' windows without any problem.  However it seems when this is done the new 'tab' has the focus...?  In my code I use the main "sSession" window to scrape some necessary data from that page's HTML...however when I create the 'tab' window I lose that functionality...it seems that my code is then trying to scrape the HTML from the 'tab' window instead of the 'main' ('sSession') window...

  How would I go about 'resetting' the focus back to the 'main' ('sSession') browser window again after each tab(s) are created?  for example:

_WD_Window($sSession, 'Switch', '{"handle":"' & $YOUR_TAB_HANDLE_GOES_HERE & '"}')  ;as stated above this will 'switch' tabs

;therefore...?

_WD_Window($sSession, 'Switch', '{"handle":"' & $sSession & '"}')  ;would be used to 'reset' focus back to the 'main' browser window?

Is that syntax correct ?  I only question it because the main browser seems to call itself...?  It is difficult for me to test this right now because of some Internet connectivity issues...I thank you in advance for any help.  Regards.

Link to post
Share on other sites

Like I stated before, Session ID and Tab Handle are not interchangeable. You can get the current tab handle with this --

$current_tab = _WD_Window($sSession, 'Window')

Once you have that, then you would use this value to switch back to this tab at any time --

_WD_Window($sSession, 'Switch', '{"handle":"' & $current_tab & '"}')

Otherwise, you can use _WD_Attach to switch to a given tab.

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Hermes
      Hi, I am trying to select elements in print page (dialog window) for a specific web page. But when trying to do so, it looks like it does not allow me to do it.
      So far, this is what I have:
      _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $mainpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $mainpagebody, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") Local $printbutton = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") _WD_ElementAction($sSession, $printbutton, 'click') _WD_LoadWait($sSession) Sleep(3000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $printpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $printpagebody, 2) The script above highlights the main web page "body" element, then clicks a tag to print a specific part of the page, then it will open a print page window where i am trying to highlight the body of that print page - but it looks like it is dropping from the session because it opens up another chrome page chrome://print.
       
      Below is the output log:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element/eb9e4673-4dec-4d4c-be6a-b7967743394b/click; $sData={"id":"eb9e4673-4dec-4d4c-be6a-b7967743394b"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... __WD_Post ==> Webdriver Exception: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C63733+2504499]\n\tOrdinal0 [0x00BFC401+2081793]\n\tOrdinal0 [0x00B024F0+1058032]\n\tOrdinal0 [0x00B55685+1398405]\n\tOrdinal0 [0x00B45E83+1334915]\n\tOrdinal0 [0x00B54CDB+1395931]\n\tOrdinal0 [0x00B45D4B+1334603]\n\tOrdinal0 [0x00B222B4+1188532]\n\tOrdinal0 [0x00B23149+1192265]\n\tGetHandleVerifier [0x00DDFB8C+1512252]\n\tGetHandleVerifier [0x00E8B0DF+2214031]\n\tGetHandleVerifier [0x00CE4BC3+484211]\n\tGetHandleVerifier [0x00CE3E69+480793]\n\tOrdinal0 [0x00C0218D+2105741]\n\tOrdinal0 [0x00C066E8+2123496]\n\tOrdinal0 [0x00C06827+2123815]\n\tOrdinal0 [0x00C0FB73+2161523]\n\tBaseThreadInitThunk [0x75EB62C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B34+1028]\n"}} _WD_ExecuteScript: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 _WD_LoadWait ==> Webdriver Exception __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}...  
      Is it even possible to select elements in print page?

    • By Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      HtmlTable2Array UDF (optional) https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      See the wiki for details on the UDF --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/
      Previous support threads (Closed)
      https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
       
    • By mLipok
      Recently I start wd_capabilities.au3 project on my side.
      I think this is time to share to AutoIt community.
      Check attached UDF: wd_capabilities.au3

      Here is a scratch example showing how to use them:
      #include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() ........ ........ ........ _WD_Capabilities_Build_Arguments(Null) ; CLEANUP ARGS _WD_Capabilities_Build_Arguments('--headless') _WD_Capabilities_Build_Arguments('start-maximized') _WD_Capabilities_Build_Arguments('disable-infobars') _WD_Capabilities_Build_Arguments('user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') Local $s_WD_Capabilities_Arguments = _WD_Capabilities_Build_Arguments(Default) ; GET ARGS _WD_Capabilities_Build_Preferences(Null) ; CLEANUP PREFS If $s_Download_dir Then _WD_Capabilities_Build_Preferences('download.default_directory', $s_Download_dir) Local $s_WD_Capabilities_Preferences = _WD_Capabilities_Build_Preferences(Default) ; GET PREFS Local $s_Desired_Capabilities = _WD_Capabilities_Build_JSON('chrome', $s_WD_Capabilities_Arguments, $s_WD_Capabilities_Preferences) Local $WD_SESSION = _WD_CreateSession($s_Desired_Capabilities) ........ ........ ........ EndFunc  
      I plan to publish the code on GitHub.
      In the indefinite future, when the project becomes more functional, if @Danp2 accepts it, I hope it may be included in the main WebDriver UDF.

      I am waiting for yours feedback and help in the further development of this project.

      REMARK 1:
      As so far this UDF only supports GoogleChrome.
      Adding support for other browsers shouldn't be difficult, I just didn't need to.

      REMARK 2:
      For now, this project is working but still as a early BETA, so please do not discuss, ask questions, or post examples or snippets of code that pertain to any function of this UDF in other part of this forum, until it is found acceptable. Simply: discusion and tests only here in this topic.


      Regards,
      @mLipok
       
    • By Hermes
      I have Index.html where it contains a frame with a source "frame1.html". I can select/highlight elements in index.html but unable to select/highlight elements inside the frame with the src "frame1.html", the autoit output is throwing error:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/2143396006437be4005db3b84acc1496/element/8be1c3c4-5bb1-42b1-8cde-7954765cbc61/element; $sData={"using":"css selector","value":"frameset:nth-of-type(1)"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\... __WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\"frameset:nth-of-type(1)\"}\n (Session info: chrome=90.0.4430.212)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00FCE7D3+124883]\n\tOrdinal0 [0x00FCE7B1+124849]\n\tGetHandleVerifier [0x01218688+193832]\n\tGetHandleVerifier [0x0123C478+340760]\n\tGetHandleVerifier [0x012361F1+315537]\n\tGetHandleVerifier [0x012516BA+427354]\n\tGetHandleVerifier [0x01236176+315414]\n\tGetHandleVerifier [0x0125174A+427498]\n\tGetHandleVerifier [0x0125D6EB+476555]\n\tGetHandleVerifier [0x0125154B+426987]\n\tGetHandleVerifier [0x01234FFD+310941]\n\tGetHandleVerifier [0x01235D8E+314414]\n\tGetHandleVerifier [0x01235D19+314297]\n\tGetHandleVerifier [0x012F31EC+1089676]\n\tGetHandleVerifier [0x012F17C9+1082985]\n\tGetHandleVerifier [0x012F13A3+1081923]\n\tGetHandleVerifier [0x013ED9FD+2115741]\n\tOrdinal0 [0x0111B82E+1488942]\n\tOrdinal0 [0x010B5A7D+1071741]\n\tOrdinal0 [0x010B559B+1070491]\n\tOrdinal0 [0x010B54B1+1070257]\n\tOrdinal0 [0x010EFF53+1310547]\n\tBaseThreadInitThunk [0x770662C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x776B1B34+1028]\n"}} Auto IT Script:
      #Include "wd_core.au3" #Include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, 'index.html') _WD_LoadWait($sSession) Local $index = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)") Local $index1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index) Local $index2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frame:nth-of-type(1)", $index1) Local $index3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "frameset:nth-of-type(1)", $index2) _WD_HighlightElement($sSession, $index2, 1) _WD_HighlightElement($sSession, $index3, 1) _WD_Shutdown() Func SetupChrome() _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":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome  

      frame1.html index.html
    • By Hermes
      Hi, sometimes when I run my script in GUI (SciTe Editor) or as an executable file, the chrome driver launches but the chrome browser does not but when I re-run the script again - chrome driver launches and so does the browser. Here is the error that I'm getting:
      __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_CreateSession: WinHTTP request timed out before Webdriver _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 Just wondering if there's a way to re-launch both the driver and browser without having to rerun the script/executable.
       
       
×
×
  • Create New...