Danp2 Posted October 8, 2019 Author Share Posted October 8, 2019 Not sure that I follow you. The ASCII code for the space character is 32. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted October 8, 2019 Share Posted October 8, 2019 (edited) that is what is im saying why is a "space" breaking my code? I'm going to try and remove the last char from the string and see if it works. it worked. i have no idea what is causing this to break other then some invisible char Edited October 8, 2019 by nooneclose Link to comment Share on other sites More sharing options...
Danp2 Posted October 8, 2019 Author Share Posted October 8, 2019 Can't really help further without the Scite output I mentioned previously. 😉 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted October 8, 2019 Share Posted October 8, 2019 @Danp2 It was a @CRLF that was causing the string to "break". Somehow between reading the email and sending the variable a @CRLF got placed at the end. I did a StringReplace($eComments, @CRLF, "") and it works now every time. I need a nap after that rabit trail which turned into a chaos tornado. 🤣 Link to comment Share on other sites More sharing options...
Letraindusoir Posted October 8, 2019 Share Posted October 8, 2019 Func _WD_ElementAction($sSession, $sElement, $sCommand, $sOption = '') Local Const $sFuncName = "_WD_ElementAction" Local $sResponse, $sResult = '', $iErr, $oJson, $sErr $sCommand = StringLower($sCommand) Switch $sCommand Case 'attribute', 'property', 'css' $sResponse = __WD_Get($_Glo_BASE_URL & ":" & $_Glo_PORT & "/session/" & $sSession & "/element/" & $sElement & "/" & $sCommand & "/" & $sOption) $iErr = @error As described in the above function, it seems that it can only be applied to a known "$sOption" of an element. How can I enumerate all the properties of this element? lcoal $a=_WD_ElementAction($sSession, $sElement,'attribute', '') or lcoal $a=_WD_ElementAction($sSession, $sElement,'attributes', '') lcoal $a=_WD_ElementAction($sSession, $sElement,'property', '') or lcoal $a=_WD_ElementAction($sSession, $sElement,'properties', '') Can't get a valid return value. Link to comment Share on other sites More sharing options...
nooneclose Posted October 8, 2019 Share Posted October 8, 2019 (edited) @Letraindusoir I think you may find your answer in the wd_core.au3 under the "_WD_ElementAction" section. if you are wanting a list of its capabilities. Edited October 8, 2019 by nooneclose Link to comment Share on other sites More sharing options...
Danp2 Posted October 8, 2019 Author Share Posted October 8, 2019 10 minutes ago, Letraindusoir said: How can I enumerate all the properties of this element? If you need to do this programmatically, then you'll need to use Javascript to retrieve the attributes collection. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
tigerwang Posted October 10, 2019 Share Posted October 10, 2019 How to set referer? I tried this :Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "test.php",default,default,'referer:www.google.com') .It works. But I don't know how to set referer with this: _WD_Navigate($sSession, "http://google.com") Link to comment Share on other sites More sharing options...
TOMLE Posted October 10, 2019 Share Posted October 10, 2019 I tried to use the demo file to modify the automated Bing search operation, but it didn't seem to work properly. Autoit3 Code: #include "wd_core.au3" #include "wd_helper.au3" #include <FileConstants.au3> Local $sDesiredCapabilities Local $iIndex Local $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.bing.com") $qinput=_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='sb_form_q']") ConsoleWrite('inputid : '&$qinput&@CR) _WD_ElementAction($sSession, $qinput, 'value', "testing 123") ;~ _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": {"goog:chromeOptions": {"w3c": true }}}}' EndFunc Console Output: _WDStartup: OS: WIN_7 WIN32_NT 7601 Service Pack 1 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.1.0.21 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --log-path="C:\Users\Administrator\Desktop\webdrv\WebDriver-0.1.0.21\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=0; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"77.0.3865.90","chrome":{"chromedriverVersion":"77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442})","userDataDir":"C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\scoped_dir3880_1172536147"},"goog:chromeOptions":{"debuggerAddress":"localhost:49946"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows nt","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"b66971f3059784520188f6236c20feda"}} _WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"77.0.3865.90","chrome":{"chromedriverVersion":"77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442})","userDataDir":"C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\scoped_dir3880_1172536147"},"goog:chromeOptions":{"debuggerAddress":"localhost:49946"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows nt","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"b66971f3059784520188f6236c20feda"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b66971f3059784520188f6236c20feda/url; $sData={"url":"https://www.bing.com"} __WD_Post: StatusCode=0; ResponseText={"value":null} _WD_Navigate: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b66971f3059784520188f6236c20feda/element; $sData={"using":"xpath","value":"//input[@id='sb_form_q']"} __WD_Post: StatusCode=0; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"7cd8d609-ef1f-44f5-a803-3eb3f044163f"}} _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"7cd8d609-ef1f-44f5-a803-3eb3f044163f"}} _WD_FindElement ==> Webdriver Exception: HTTP status = 0 inputid : __WD_Post: URL=HTTP://127.0.0.1:9515/session/b66971f3059784520188f6236c20feda/element//value; $sData={"id":"", "text":"testing 123"} __WD_Post: StatusCode=0; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=77.0.3865.90)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0119EB13+1501971]\n\tOrdinal0 [0x0111F6D1+980689]\n\tOrdinal0 [0x010A765F+489055]\n\tOrdinal0 [0x01046A89+92809]\n\tOrdinal0 [0x01043720+79648]\n\tOrdinal0 [0x01057A4D+162381]\n\tOrdinal0 [0x01042656+75350]\n\tOrdinal0 [0x01057C61+162913]\n\tOrdinal0 [0x0105F93E+194878]\n\tOrdinal0 [0x010578EB+162027]\n\tOrdinal0 [0x01040AC7+68295]\n\tOrdinal0 [0x01041B40+72512]\n\tOrdinal0 [0x01041AD9+72409]\n\tOrdinal0 [0x01138F37+1085239]\n\tGetHandleVerifier [0x0123D7ED+503293]\n\tGetHandleVerifier [0x0123D580+502672]\n\tGetHandleVerifier [0x012446AC+531644]\n\tGetHandleVerifier [0x0123DFFA+505354]\n\tOrdinal0 [0x01130606+1050118]\n\tOrdinal0 [0x0113047F+1049727]\n\tOrdinal0 [0x0113AF9B+1093531]\n\tOrdinal0 [0x0113B103+1093891]\n\tOrdinal0 [0x0113A095+1089685]\n\tBaseThreadInitThunk [0x7693343D+18]\n\tRtlInitializeExceptionChain [0x77039802+99]\n\tRtlInitializeExceptionChain [0x770397D5+54]\n"}} _WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Ses... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=77.0.3865.90)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0119EB13+1501971]\n\tOrdinal0 [0x0111F6D1+980689]\n\tOrdinal0 [0x010A765F+489055]\n\tOrdinal0 [0x01046A89+92809]\n\tOrdinal0 [0x01043720+79648]\n\tOrdinal0 [0x01057A4D+162381]\n\tOrdinal0 [0x01042656+75350]\n\tOrdinal0 [0x01057C61+162913]\n\tOrdinal0 [0x0105F93E+194878]\n\tOrdinal0 [0x010578EB+162027]\n\tOrdinal0 [0x01040AC7+68295]\n\tOrdinal0 [0x01041B40+72512]\n\tOrdinal0 [0x01041AD9+72409]\n\tOrdinal0 [0x01138F37+1085239]\n\tGetHandleVerifier [0x0123D7ED+503293]\n\tGetHandleVerifier [0x0123D580+502672]\n\tGetHandleVerifier [0x012446AC+531644]\n\tGetHandleVerifier [0x0123DFFA+505354]\n\tOrdinal0 [0x01130606+1050118]\n\tOrdinal0 [0x0113047F+1049727]\n\tOrdinal0 [0x0113AF9B+1093531]\n\tOrdinal0 [0x0113B103+1093891]\n\tOrdinal0 [0x0113A095+1089685]\n\tBaseThreadInitThunk [0x7693343D+18]\n\tRtlInitializeExceptionChain [0x77039802+99]\n\tRtlInitializeExceptionChain [0x770397D5+54]\n"}} Link to comment Share on other sites More sharing options...
tigerwang Posted October 10, 2019 Share Posted October 10, 2019 @Danp2 When I run the program ,it will open a new firefox without any extension. I want to get the existed extensions I‘ve installed before in firefox.What should I do? I tried this code:$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"args": ["-profile", "C:\\Users\\gens\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\g2h1nwi0.default-release"]}}', but it did't work. Or how to install brower extensions automatically? Thanks Link to comment Share on other sites More sharing options...
Danp2 Posted October 10, 2019 Author Share Posted October 10, 2019 7 hours ago, tigerwang said: How to set referer? I tried this :Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "test.php",default,default,'referer:www.google.com') .It works. But I don't know how to set referer with this: _WD_Navigate($sSession, "http://google.com") Not something I've needed to do, and some quick research seems to indicate that you need to use a proxy to accomplish this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted October 10, 2019 Author Share Posted October 10, 2019 (edited) 5 hours ago, TOMLE said: _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"7cd8d609-ef1f-44f5-a803-3eb3f044163f"}} _WD_FindElement ==> Webdriver Exception: HTTP status = 0 inputid : Not sure why this would be occurring. When I ran your code, it executed fine for me. It appears that we are using the same version of all components. <shrug> I seem to recall an earlier bug where the function improperly returned the Webdriver Exception error, but I thought this had been addressed already. I'll take another peek at the code to see if I can see why this might occur. Edit: Quote __WD_Post: StatusCode=0; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"7cd8d609-ef1f-44f5-a803-3eb3f044163f"}} This is the issue. StatusCode here should be 200, not 0. Edit #2: Now I remember the cause. You need to update to the latest version of the WinHTTP UDF to resolve this issue. Edited October 10, 2019 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted October 10, 2019 Author Share Posted October 10, 2019 @tigerwang See my prior response here -- tigerwang 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TOMLE Posted October 10, 2019 Share Posted October 10, 2019 @Danp2 As you said, after I tried to update WinHTTP, the problem was solved. Thank you very much for your technical support! Danp2 1 Link to comment Share on other sites More sharing options...
tigerwang Posted October 11, 2019 Share Posted October 11, 2019 22 hours ago, Danp2 said: Not something I've needed to do, and some quick research seems to indicate that you need to use a proxy to accomplish this. Maybe my idea is not clear.We can load page by _WD_Navigate($sSession,$url) so far.I want to get referer in the page of $url. Like this:_WD_Navigate($sSession,$url,$referer). I can get the $referer in the $url page. It means that someone comes to the $url page from the $referer page. I could't set it like that. Could you give me some advice? Link to comment Share on other sites More sharing options...
Danp2 Posted October 11, 2019 Author Share Posted October 11, 2019 @tigerwang I understood your intent. Unfortunately, it doesn't appear that this functionality is included in the Webdriver specs. You can check them out yourself here. Can you give a specific example where you need this functionality? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Letraindusoir Posted October 11, 2019 Share Posted October 11, 2019 (edited) $sElement1 = _WD_FindElement($sSession,"xpath",'//*[@id="' & $sEleID & '"]') $sResp = _WD_ExecuteScript($sSession, 'var e = document.getElementById("' & $sEleID & '");return e;', '') $oJSon = Json_Decode($sResp) $sElement2 = Json_Get($oJSon, '[value]["element-6066-11e4-a52e-4f735466cecf"]') $sS = "" $sS &= 'var xresult = document.evaluate("//*[@id=' & "'" & $sEleID & "'" & ']", document, null, XPathResult.ANY_TYPE, null);' $sS &= 'var xnodes = [];' $sS &= 'var xres;' $sS &= 'while (xres = xresult.iterateNext()) {' $sS &= ' xnodes.push(xres);' $sS &= ' };' $sS &= 'return xnodes;' $sResp = _WD_ExecuteScript($sSession, $sS, '') $oJSon = Json_Decode($sResp) $sElement3 = Json_Get($oJSon, '[value][0]["element-6066-11e4-a52e-4f735466cecf"]') After running the above script, By comparison ,shows that $sElement1=$sElement2=$sElement3. It feels like there's an inner relationship between them. Is there any way to convert or map "$sElement1" to a DOM or Javascript object so that we can manipulate the web page directly by calling the object's methods or properties? Edited October 11, 2019 by Letraindusoir Link to comment Share on other sites More sharing options...
Danp2 Posted October 11, 2019 Author Share Posted October 11, 2019 22 minutes ago, Letraindusoir said: By comparison ,shows that $sElement1=$sElement2=$sElement3. Why would you expect these to be different when you're using the same criteria to select them? Also, why not post an example we can actually run rather than just this snippet of code? 23 minutes ago, Letraindusoir said: Is there any way to convert or map "$sElement1" to a DOM or Javascript object so that we can manipulate the web page directly by calling the object's methods or properties? Yes... you pass $sElement1 as a parameter to _WD_ExecuteScript and then access that parameter within the executed javascript. I believe there are already examples of this on the forum. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
OneSolution Posted October 13, 2019 Share Posted October 13, 2019 (edited) Hello everyone! I have a quick questions on how to use jQuery in this code to select the text. <div class="cx-item-contents">4:00 am</div><div class="cx-item-contents">8:00 am</div> <div class="cx-item-contents">10:00 am</div><div class="cx-item-contents">8:00 am</div> $sButton = _WD_ExecuteScript($sSession, "jQuery('.cx-item-contents').click()") When I run the above script it select all of the checkbox with the class=cx-item-contents. How do I make it select the box by the text only. Example! check both 8:00 am boxes or check 4:00 am plus 10:00 am box only. Thanks in advanced!!! Edited October 13, 2019 by OneSolution Link to comment Share on other sites More sharing options...
Danp2 Posted October 13, 2019 Author Share Posted October 13, 2019 Have you looked into the :contains selector? That should allow you to accomplish your goal. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts