tigerwang Posted October 14, 2019 Share Posted October 14, 2019 A new problem occured. I edit the program on windows server 2016. The geckodriver can't run at all whatever its version is 32 bit or 64 bit. All debug info is below: "C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\soft\autoit\autoit\au3\ad.au3" _WDStartup: OS: WIN_2016 WIN32_NT 14393 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.1.0.21 _WDStartup: Driver: C:\soft\autoit\autoit\au3\geckodriver.exe _WDStartup: Params: --log trace --connect-existing --marionette-port 2828 _WDStartup: Port: 4444 __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_CreateSession: 0 _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 >Exit code: 0 Time: 1.979 It won't show the command window when I click the geckodriver.exe. However the same code can run well in local machine (Win10). I'm sure I close the firewall on windows server 2016. Somebody could help me?? Link to comment Share on other sites More sharing options...
tigerwang Posted October 14, 2019 Share Posted October 14, 2019 If I click the chromedriver.exe,it can show command window on windows server 2016😂 Link to comment Share on other sites More sharing options...
Danp2 Posted October 14, 2019 Author Share Posted October 14, 2019 2 hours ago, tigerwang said: A new problem occured. I edit the program on windows server 2016. The geckodriver can't run at all whatever its version is 32 bit or 64 bit. All debug info is below: Sounds like this is an issue with your Windows installation, which isn't caused by this UDF. It's likely a security / rights issue. Have you tried the following? Right click on the geckodriver executable Select the Properties entry at the bottom Look for and click the Unblock checkbox Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
tigerwang Posted October 14, 2019 Share Posted October 14, 2019 41 minutes ago, Danp2 said: Sounds like this is an issue with your Windows installation, which isn't caused by this UDF. It's likely a security / rights issue. Have you tried the following? Right click on the geckodriver executable Select the Properties entry at the bottom Look for and click the Unblock checkbox I tried,but it did't work. Link to comment Share on other sites More sharing options...
nooneclose Posted October 14, 2019 Share Posted October 14, 2019 (edited) Morning! Quick question, how do I get the value of an input field with WebDriver? I know how to send values to an input field but I don't know how to read the value of an input field. Local $woTrack = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='nav_search_fld']") _WD_ElementAction($sSession, $woTrack, 'value', "work order tracking") _WD_ElementAction($sSession, $woTrack, 'text') I use this to send data but I also want to check what value is in that field to make sure the data was properly sent. I figured it out: Here is the code I use to test against what was sent to the input field. ; Send Data to Description Local $eDescription = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='mad3161b5-tb2']") Do _WD_ElementAction($sSession, $eDescription, 'value', $testDesc) _WD_ElementAction($sSession, $eDescription, 'text') Local $test92 = _WD_ElementAction($sSession, $eDescription, 'property', 'value') ConsoleWrite(@CRLF & "$test92: " & $test92 & @CRLF) Sleep(500) Until $test92 = $testDesc This is more effective and efficient than using sleep which may be skipped or waste large amounts of time. Edited October 14, 2019 by nooneclose Figured out the solution Link to comment Share on other sites More sharing options...
Danp2 Posted October 15, 2019 Author Share Posted October 15, 2019 12 hours ago, tigerwang said: I tried,but it did't work. Unfortunately, you will need to troubleshoot / resolve this on your own. The system logs would be a good place to start. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted October 15, 2019 Author Share Posted October 15, 2019 11 hours ago, nooneclose said: _WD_ElementAction($sSession, $woTrack, 'text') This is retrieving the value of the input field. You just aren't assigning the returned value to a variable. 😄 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
phoving Posted October 15, 2019 Share Posted October 15, 2019 Hi everyone. I have this issue: The webdriver returns the title of the page differently then _WD_GET displays it. This is in my log: 1571135606630 webdriver::server DEBUG -> GET /session/dd2a1e5d-f315-474f-bae9-84341b4af31c/title 1571135606632 webdriver::server DEBUG <- 200 OK {"value":"CAS – Central Authentication Service"} __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS û Central Authentication Service"}... It must have something to do with the charset. Anyone knows how to handle this issue? Link to comment Share on other sites More sharing options...
Danp2 Posted October 15, 2019 Author Share Posted October 15, 2019 @phoving You'll need to provide more details. Some things to consider -- What is the default codepage for your Windows installation? Are you running a non-English version of Windows? Can you provide a short script that demonstrates the issue? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
phoving Posted October 15, 2019 Share Posted October 15, 2019 5 hours ago, Danp2 said: @phoving You'll need to provide more details. Some things to consider -- What is the default codepage for your Windows installation? Are you running a non-English version of Windows? Can you provide a short script that demonstrates the issue? The default codepage is: C:\>chcp Active code page: 850 C:\> The windows version is Dutch. The script is very simple. I request the title of a page. The title of the page is: "CAS – Central Authentication Service". But __WD_GET returns it as "CAS û Central Authentication Service". So if I want to check the title in my script it fails. This is the script where I get the title: Func __EUP_GETTITLE() Local $sURL = $_WD_BASE_URL & ":" & $_WD_PORT & "/session/"& $__g_aEUP[$EUP_WD_SESSION][0] & "/title" Local $sResponse = __WD_Get($sURL) Local $sJSON = Json_Decode($sResponse) Return Json_Get($sJSON, "[value]") EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted October 15, 2019 Author Share Posted October 15, 2019 @phoving You are using a function that was intended for internal use only by the UDF's other functions. Can you explain why you aren't using the standard _WD_* functions? Have you tried calling _WD_Action instead? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
phoving Posted October 17, 2019 Share Posted October 17, 2019 On 10/15/2019 at 9:58 PM, Danp2 said: @phoving You are using a function that was intended for internal use only by the UDF's other functions. Can you explain why you aren't using the standard _WD_* functions? Have you tried calling _WD_Action instead? No special reason, but I think that has nothing to do with the issue I am experiencing. Calling _WD_Action instead has this result: __WD_Get: URL=HTTP://127.0.0.1:4444/session/5b32358c-5a45-4e34-a370-0a6eceae403d/title 1571289885717 webdriver::server DEBUG -> GET /session/5b32358c-5a45-4e34-a370-0a6eceae403d/title 1571289885724 webdriver::server DEBUG <- 200 OK {"value":"CAS – Central Authentication Service"} __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS û Central Authentication Service"}... _WD_Action: {"value":"CAS û Central Authentication Service"} I thought it has to do with the iMode in which _WinHttpSimpleRequest is called. I see this in the function header: ; $iMode - [optional] reading mode of result ; |0 - ASCII-text ; |1 - UTF-8 text ; |2 - binary data But in tests I did not see any solution. Link to comment Share on other sites More sharing options...
Danp2 Posted October 17, 2019 Author Share Posted October 17, 2019 @phoving If you can, please test this on an English version of Windows. Also, we could look further into it if you could provide the URL. FWIW, I found a public site with this same title (https://cas.uga.edu/cas/login) and I get the expected result on this end. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
phoving Posted October 18, 2019 Share Posted October 18, 2019 @Danp2 I tested on an english windows, and got the same result. I also changed the region settings / dat / time format etc. all to Central US. You say you got the expected result. Is that: you got the same as I got, or do you get the "good" string? I do not understand how the webdriver can display the string correctly, but __WD_GET not. Link to comment Share on other sites More sharing options...
Danp2 Posted October 18, 2019 Author Share Posted October 18, 2019 @phoving This is what I got when testing both sites -- __WD_Get: URL=HTTP://127.0.0.1:9515/session/c3566cf2620999fd9d670c32ad9d82e3/title __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS – Central Authentication Service"}... _WD_Action: {"value":"CAS – Central Authentication Service"} Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
OneSolution Posted October 21, 2019 Share Posted October 21, 2019 On 10/13/2019 at 4:42 AM, Danp2 said: Have you looked into the :contains selector? That should allow you to accomplish your goal. Yes it took me sometime to figured it out!! Thank you so much!!! Link to comment Share on other sites More sharing options...
Davidowicza Posted November 1, 2019 Share Posted November 1, 2019 (edited) Hey all, I am having an issue getting the _WD functions to locate this link that I need to click on. Link element that I need to click: <a href="/admintool/servlet/servlet.FileDownload?file=00Pt000000ICYQHEA5" target="_BLANK" class="actionLink">Review.pdf</a> Xpath: //*[@id="j_id0:theForm:j_id31:j_id33:0:j_id36"]/a iFrame that it is in: <iframe allow="geolocation *; microphone *; camera *" frameborder="0" height="80%" id="j_id71" name="j_id71" src="website" title="Content" width="100%"></iframe> What I have tried so far: _WD_FrameEnter($sSession,"j_id71") ;I have tried all this code without entering the frame too if @error Then MsgBox(0, "Frame", @error) ;Does not throw error so I know I am in the frame _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='j_id0:theForm:j_id31:j_id33:0:j_id36']/a"), 0, 10000) if @error Then MsgBox(0, "ByXpath", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/form/div[2]/div/div/div[1]/table/tbody/tr/td[1]/a"), 0, 10000) ;Not sure if this even works but I tried it anyway if @error Then MsgBox(0, "ByFullXpath", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByLinkText, "Review.pdf", 0, 10000) if @error Then MsgBox(0, "ByLinkText", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review.pdf", 0, 10000) if @error Then MsgBox(0, "ByPartialText", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review", 0, 10000) if @error Then MsgBox(0, "ByPartialText2", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".actionLink") if @error Then MsgBox(0, "ByCSS", @error) All of these return @error = 7 (timeout) even though the element is loaded (takes half a second to appear on the screen) and I am completely stumped on another way to interact with it. And obviously since I cannot get my script to locate this element, all of the 'click' interactions return "No Match". Anymore suggestions would be super helpful! Thanks! PS: Unfortunately I cannot share this website since it has private information on it, but I will give as much info as I can. Edited November 1, 2019 by Davidowicza Link to comment Share on other sites More sharing options...
Danp2 Posted November 1, 2019 Author Share Posted November 1, 2019 @Davidowicza You aren't correctly entering the frame. Please review the DemoFrames function in wd_demo.au3 for a working example. P.S. Currently the _WD_Frame* functions don't set the @error flag like most of the other functions in the UDF. Davidowicza 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Davidowicza Posted November 1, 2019 Share Posted November 1, 2019 (edited) @Danp2 Thank you again! I figured I had to be missing something obvious... Spent about 4 hours trying to figure it out but never guessed it was because of how I was entering the iFrame...it works like a charm! Edited November 1, 2019 by Davidowicza Danp2 1 Link to comment Share on other sites More sharing options...
tigerwang Posted November 2, 2019 Share Posted November 2, 2019 How To set UserAgent? I tried this: _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"setWindowRect":true,"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"browserName":"chrome","browserVersion":"45"}}' But it still shows the real useragent :firefox....... when use _WD_Navigate. Link to comment Share on other sites More sharing options...
Recommended Posts