Danp2 Posted November 9, 2018 Author Share Posted November 9, 2018 @thuong12382 You need to establish the location of the web driver. Please review the demo script (wd_demo.au3), which contains working examples for many of the functions. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted November 9, 2018 Share Posted November 9, 2018 Hello Dan, we were using FFau3 together with MozRepl and want to change to your UDF. We did not find a function to read content from a webpage element. Is it _WD_Action or _WD_ElementAction? How does it work? Another question: does _WD_LoadWait return the same as _WD_FindElement? If not, that would save code. Have a nice weekend Hans Link to comment Share on other sites More sharing options...
Danp2 Posted November 9, 2018 Author Share Posted November 9, 2018 Hi Hans, You would use _WD_ElementAction to interact with an element. To retrieve its value, use 'text' as the value for the $sCommand parameter. 3 hours ago, HJL said: Another question: does _WD_LoadWait return the same as _WD_FindElement? If not, that would save code. This has been previously suggested for _WD_WaitElement. Is that what you mean? If not, please elaborate. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 10, 2018 Share Posted November 10, 2018 Here is my radio buttons example: My example radio buttons Here is my simple code: #include <wd_core.au3> #include <wd_helper.au3> Local $sDesiredCapabilities, $sSession 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 ;==>SetupChrome SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio") $radio_4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='checkmark']") _WD_ElementAction($sSession, $radio_4, 'click') _WD_Shutdown() Can you help me to choose the radio button "Four". I have tried several times. I am new to this UDF, html and css. Thank you <3 Link to comment Share on other sites More sharing options...
Danp2 Posted November 10, 2018 Author Share Posted November 10, 2018 That site uses iframes, so you'll need to switch to the correct frame before you can locate the element with WD_FindElement. This can be done with _WD_Window or the helper function _WD_FrameEnter. Check out the DemoFrames function in wd_demo.au3 for an example of using these functions. pempemHY 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 11, 2018 Share Posted November 11, 2018 On 10/11/2018 at 10:38 AM, Danp2 said: That site uses iframes, so you'll need to switch to the correct frame before you can locate the element with WD_FindElement. This can be done with _WD_Window or the helper function _WD_FrameEnter. Check out the DemoFrames function in wd_demo.au3 for an example of using these functions. expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" Local Enum $eFireFox = 0, _ $eChrome Local $aDemoSuite[][2] = [["DemoTimeouts", False], ["DemoNavigation", False], ["DemoElements", False], ["DemoScript", False], ["DemoCookies", False], ["DemoAlerts", False],["DemoFrames", False], ["DemoActions", True]] Local Const $_TestType = $eFireFox Local $sDesiredCapabilities Local $iIndex Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio") ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='iframeResult']") _WD_FrameEnter($sSession, $sElement) $text = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input") _ArrayDisplay($text) _WD_FrameLeave($sSession) Sleep(30000) _WD_DeleteSession($sSession) _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 }}}}' EndFunc I have tried that example but i still don't know how to click that radio or reach to its ID . I am noob, can you tell clearlier? Link to comment Share on other sites More sharing options...
Danp2 Posted November 11, 2018 Author Share Posted November 11, 2018 That site is odd because it's using a custom radio button, but here's two ways to select the radio buttons -- expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities Local $iIndex Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio") ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='iframeResult']") _WD_FrameEnter($sSession, $sElement) ; Method 1 $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//label[3]/input") _WD_ElementAction($sSession, $sElement, 'click') Sleep(3000) ; Method 2 $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input", "", True) ;_ArrayDisplay($aElements) _WD_ElementAction($sSession, $aElements[0], 'click') Sleep(3000) _WD_FrameLeave($sSession) _WD_DeleteSession($sSession) _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 }}}}' EndFunc ;==>SetupChrome pempemHY 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 11, 2018 Share Posted November 11, 2018 Thank you very much!!! Link to comment Share on other sites More sharing options...
HJL Posted November 12, 2018 Share Posted November 12, 2018 On 9.11.2018 at 2:09 PM, Danp2 said: Hi Hans, You would use _WD_ElementAction to interact with an element. To retrieve its value, use 'text' as the value for the $sCommand parameter. This has been previously suggested for _WD_WaitElement. Is that what you mean? If not, please elaborate. _WD_WaitElement is what I was looking for - perfect. Thanks for your help and for this UDF.... Link to comment Share on other sites More sharing options...
pempemHY Posted November 20, 2018 Share Posted November 20, 2018 Hi Dan, when i choose the $Command is 'action' in the function _WD_Action, can i control the page to scroll down? And how to do it? Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Author Share Posted November 20, 2018 @pempemHY Please provide a better description of what you are attempting to accomplish. Show us what you've tried thus far. P.S. There may be a better way than using "actions". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 20, 2018 Share Posted November 20, 2018 #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities Local $iIndex Local $sSession $_WD_DEBUG = $_WD_DEBUG_Info SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.youtube.com/") Sleep(500) _WD_Action($sSession, "actions", 'PageDown') ;ControlSend($handles, "", $controlID, '{PGDN}') Sleep(20000) _WD_DeleteSession($sSession) _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 }}}}' EndFunc i try this with Youtube, key wasn't sent. Should i use ControlSend? Can i get controlID and handle of my session with this UDF? Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Author Share Posted November 20, 2018 In many cases, the scrolling will occur automatically once you interact with an element. Why do you want to scroll the view? Again, what's your end goal? pempemHY 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 20, 2018 Share Posted November 20, 2018 Thank you, my problem was solved. Some elements at the bottom of the page (must use PageDown if you wan to see them) can't be interacted,.To solve this, i have set fullscreen chrome and it's OK. Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Author Share Posted November 20, 2018 @pempemHY I'd like to better understand the issue. Can you post an example, ideally with a publicly accessible website, where you can't interact with the element unless the browser is full screen? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Acanis Posted November 20, 2018 Share Posted November 20, 2018 Hey Danp2, thanks for creating this UDF Didnt code some time, so maybe Iam just confused, but I cant get it to run^^... I downloaded the UDFs JSON, WinHttp and this one. I unpacked the chromedriver in the same folder with wd_demo. I started the demo with SciTE and changed: Local Const $_TestType = $eChrome I start the demo (1 Chrome window is already open), and nothing happens with Chrome. All I can see, is that the driver is opening. Iam using the newest Chrome version, every UDF and the driver are fresh downloaded, my AutoIt version is: 3.3.14.2 The demo is closing after a few seconds, my console says: expandcollapse popup_WDStartup: OS: WIN_10 WIN32_NT 17134 _WDStartup: AutoIt: 3.3.14.2 _WDStartup: WD.au3: 0.1.0.15 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --log-path="C:\Users\Acanis\Downloads\Chromedriver\chrome.log" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"unrecognized capability: chromeOptions","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD4CB0+1526960]\n\tOrdinal0 [0x00C40C1D+920605]\n\tOrdinal0 [0x00BE5177+545143]\n\tOrdinal0 [0x00B65B94+23444]\n\tOrdinal0 [0x00B8CA63+182883]\n\tOrdinal0 [0x00B8D0B7+184503]\n\tOrdinal0 [0x00B8CEAD+183981]\n\tOrdinal0 [0x00B8B95B+178523]\n\tOrdinal0 [0x00B737A0+79776]\n\tOrdinal0 [0x00B74D5C+85340]\n\tOrdinal0 [0x00B74CB0+85168]\n\tGetHandleVerifier [0x00D8E1F1+584865]\n\tOrdinal0 [0x00CE3F63+1589091]\n\tOrdinal0 [0x00CE413D+1589565]\n\tOrdinal0 [0x00CE438A+1590154]\n\tOrdinal0 [0x00CDC937+1558839]\n\tOrdinal0 [0x00CE3DDF+1588703]\n\tOrdinal0 [0x00C5805E+1015902]\n\tOrdinal0 [0x00C643AB+1065899]\n\tOrdinal0 [0x00C644FA+1066234]\n\tOrdinal0 [0x00C63555+1062229]\n\tBaseThreadInitThunk [0x75718484+36]\n\tRtlValidSecurityDescriptor [0x77BE302C+284]\n\tRtlValidSecurityDescriptor [0x77BE2FFA+234]\n"}} _WD_CreateSession: {"value":{"error":"invalid argument","message":"unrecognized capability: chromeOptions","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD4CB0+1526960]\n\tOrdinal0 [0x00C40C1D+920605]\n\tOrdinal0 [0x00BE5177+545143]\n\tOrdinal0 [0x00B65B94+23444]\n\tOrdinal0 [0x00B8CA63+182883]\n\tOrdinal0 [0x00B8D0B7+184503]\n\tOrdinal0 [0x00B8CEAD+183981]\n\tOrdinal0 [0x00B8B95B+178523]\n\tOrdinal0 [0x00B737A0+79776]\n\tOrdinal0 [0x00B74D5C+85340]\n\tOrdinal0 [0x00B74CB0+85168]\n\tGetHandleVerifier [0x00D8E1F1+584865]\n\tOrdinal0 [0x00CE3F63+1589091]\n\tOrdinal0 [0x00CE413D+1589565]\n\tOrdinal0 [0x00CE438A+1590154]\n\tOrdinal0 [0x00CDC937+1558839]\n\tOrdinal0 [0x00CE3DDF+1588703]\n\tOrdinal0 [0x00C5805E+1015902]\n\tOrdinal0 [0x00C643AB+1065899]\n\tOrdinal0 [0x00C644FA+1066234]\n\tOrdinal0 [0x00C63555+1062229]\n\tBaseThreadInitThunk [0x75718484+36]\n\tRtlValidSecurityDescriptor [0x77BE302C+284]\n\tRtlValidSecurityDescriptor [0x77BE2FFA+234]\n"}} _WD_CreateSession ==> Webdriver Exception: unrecognized capability: chromeOptions Bypass: DemoTimeouts Bypass: DemoNavigation Bypass: DemoElements Bypass: DemoScript Bypass: DemoCookies Bypass: DemoAlerts Bypass: DemoFrames Running: DemoActions __WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"http://google.com"} __WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} _WD_Navigate: {"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//input[@id="lst-ib"]"} __WD_Post: StatusCode=400; ResponseText=missing command parameters _WD_FindElement: missing command parameters _WD_FindElement ==> Webdriver Exception: HTTP status = 400 $sElement = $sAction = {"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"","element-6066-11e4-a52e-4f735466cecf":""}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]} __WD_Post: URL=HTTP://127.0.0.1:9515/session//actions; $sData={"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"","element-6066-11e4-a52e-4f735466cecf":""}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]} __WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} _WD_Action: {"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} __WD_Delete: URL=HTTP://127.0.0.1:9515/session//actions __WD_Delete: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} _WD_Action: {"sessionId":"","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}} __WD_Delete: URL=HTTP://127.0.0.1:9515/session/ __WD_Delete: StatusCode=200; ResponseText={"sessionId":"","status":0,"value":null} _WD_DeleteSession: {"sessionId":"","status":0,"value":null} +>19:09:44 AutoIt3.exe ended.rc:0 +>19:09:44 AutoIt3Wrapper Finished. >Exit code: 0 Time: 11.23 The log says: Quote [1542737373.914][INFO]: [c19acd60b4cea2210aa6468670f02ae6] COMMAND InitSession { "capabilities": { "alwaysMatch": { "chromeOptions": { "w3c": true } } } } [1542737373.920][INFO]: [c19acd60b4cea2210aa6468670f02ae6] RESPONSE InitSession ERROR invalid argument: unrecognized capability: chromeOptions Do you know, what Iam doing wrong? Thanks Aca Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Author Share Posted November 20, 2018 (edited) @Acanis It appears that they changed something in the latest version of ChromeDriver. I'll post back if I get it working. Dan P.S. You could also try downgrading to the prior version of ChromeDriver. Edited November 20, 2018 by Danp2 Acanis 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Author Share Posted November 20, 2018 Ok... it looks like "chromeOptions" has been changed to "goog:chromeOptions". I'll change this in wd_demo and will be releasing an update to the UDF soon. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
pempemHY Posted November 21, 2018 Share Posted November 21, 2018 (edited) On 20/11/2018 at 10:10 PM, Danp2 said: @pempemHY I'd like to better understand the issue. Can you post an example, ideally with a publicly accessible website, where you can't interact with the element unless the browser is full screen? Try this code! Then delete the line "_WD_Window($sSession, 'fullscreen')" and try it again . See the difference. Edited December 4, 2018 by pempemHY My security Link to comment Share on other sites More sharing options...
Danp2 Posted November 21, 2018 Author Share Posted November 21, 2018 @pempemHY I tried running your code, but it seemed to get hung up in this area -- $button_go = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='u_0_1w']") _WD_ElementAction($sSession, $button_go, 'click') Not sure what this should be doing. Would really help if you could provide a much simpler example to review. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now