Danp2 Posted April 17, 2020 Author Share Posted April 17, 2020 15 minutes ago, Retaki said: why i need to look at _WD_WaitElement? what did you notice in my code? is the Wait Element doing the same am doing in the code i posted? Yes, which you would have known if you looked at the function as suggested. 😋 17 minutes ago, Retaki said: In this example there is a pop is already displayed, I can easily access it using the getElement function but how i can check if its already displayed or not? You could try -- $lIsVisible = _WD_ElementAction($sSession, $sElement, 'displayed') This is what I used in _WD_WaitElement when checking for an element's visibility. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Retaki Posted April 17, 2020 Share Posted April 17, 2020 Thanks @Danp2, that last example was really helpful. Link to comment Share on other sites More sharing options...
Purity8 Posted April 18, 2020 Share Posted April 18, 2020 (edited) I'm new AutoIt (& Windows API). I've searched this topic & around forums, but I still don't quite understand the basic uses. Where can I find instructions for finding out what each 'code' means? Example: $sElement = Object (Image/Video) or Text string $sUrl = Website Link variable $sSession = FireFox session? $sNodeName = ? $sDesiredCapabilities = ? What does "Local" and "Global" mean? This includes things like: What does the small s after $ mean? In other words, I'm trying to find out "What are these?" oppose to "How do I use it?" Edited April 18, 2020 by Purity8 Added more info Link to comment Share on other sites More sharing options...
Danp2 Posted April 18, 2020 Author Share Posted April 18, 2020 @Purity8 Mose of your questions can be answered by either -- Looking it up in the help file (ex: local vs global) Reviewing the examples in wd_demo.au3 The items you posted above are just variables, so their contents / meaning could change depending on the context in which they are used. Please review the above and then get back to us with any specific questions you may have. Dan P.S. Thanks to the Admin for moving this to the support thread! Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheXman Posted April 18, 2020 Share Posted April 18, 2020 @Purity8 another good source for AutoIt-related information is the AutoIt Wiki. For instance, answers to your specific questions, in your previous post, can be found in the Wiki's Best Coding Practices topic. Danp2 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Nine Posted April 18, 2020 Share Posted April 18, 2020 The wiki is also a very good source of information. To answer the question about the small s after $, review this document of best code practices in wiki. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Purity8 Posted April 18, 2020 Share Posted April 18, 2020 (edited) My apologies for putting in the wrong section. a) @Danp2, I'll go ahead & read all those *.au3 files then. Quote The items you posted above are just variables I needed that confirmation, just wanted to make sure. b) @TheXman, I had been to the wiki page, but wasn't able to find the specifics. Bingo! c) @Nine, That's exactly what I was looking for! Thanks everyone! 👍 👌 Edited April 18, 2020 by Purity8 Link to comment Share on other sites More sharing options...
Retaki Posted April 18, 2020 Share Posted April 18, 2020 @Danp2, I do really facing a critical issue, i can select a value from a drop down box easily, but i cannot retrieve the current selected value, it always return nothing. <select class="form-control input-sm" id="dialog_settings_object_sensor_type" onchange="settingsObjectSensorType();"> <option value="acc">Ignition (ACC)</option> <option value="di">Digital input</option> <option value="do">Digital output</option> <option value="fuel">Fuel level</option> <option value="temperature">Temprature</option> <option value="humidity">Humadity</option> <option value="door">DOOR</option> <option value="refrigerator">Refrigerator</option> <option value="cust">Custom</option> <option value="cust_weight">WEIGHT</option> <option value="cust_low_high">Custom Low High</option> <option value="water">Water</option> <option value="rfid"> RFID </option> </select> Am using _WD_ElementAction Link to comment Share on other sites More sharing options...
Retaki Posted April 18, 2020 Share Posted April 18, 2020 (edited) Well, i get the value i want using a Javascript "_WD_ExecuteScript($sSession, "var x = document.getElementById('dialog_settings_object_sensor_type').value; alert(x); ")". I do not know how to get that variable to autoit variable. ----------- _WD_ExecuteScript($sSession, "var m = document.getElementById('dialog_settings_object_sensor_units'); var x = document.getElementById('dialog_settings_object_sensor_type').value; m.value = x; ") I solved it by assigning the value to another text box then read that text box and know the value, but am not sure if this is the optimal solution. Edited April 18, 2020 by Retaki Link to comment Share on other sites More sharing options...
Danp2 Posted April 18, 2020 Author Share Posted April 18, 2020 @Retaki Here's the way I would do it -- #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $mainElement _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') _WD_Startup() $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/select$samples/Basic_select?revision=1617239") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select") If @error = $_WD_ERROR_Success Then $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}' $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].value", $sJsonElement) $oJson = Json_Decode($sResponse) $sResult = Json_Get($oJson, "[value]") ConsoleWrite($sResult & @CRLF) EndIf I'm guessing that this will be a common question, so will probably add a helper function for this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Retaki Posted April 18, 2020 Share Posted April 18, 2020 Thanks @Danp2, i do think there is an issue, cause it failed to parse this line $oJson = Json_Decode($sResponse) ==> Unable to parse line.: $oJson = Json_Decode($sResponse)? $oJson = Json_Decode($sResponse)^ ERROR >Exit code: 1 Time: 0.3098 Link to comment Share on other sites More sharing options...
Danp2 Posted April 18, 2020 Author Share Posted April 18, 2020 @Retaki When you copy / paste code from the forum, sometimes it results in some "hidden" characters being inserted into the code. If you go to the end of that line and press the backspace key, that should remove the extra character. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Retaki Posted April 18, 2020 Share Posted April 18, 2020 Thanks @Danp2, You were right as usual Danp2 1 Link to comment Share on other sites More sharing options...
Purity8 Posted April 19, 2020 Share Posted April 19, 2020 (edited) @Danp2 Sorry, I'm a little confused. According to this site:https://www.autoitscript.com/wiki/WebDriver#Requirements I need a total of 4 files, but one of them does not have anything do download. Json - check WinHttp - check WebDriver (Gecko) - checkindependent WebDriver - missing? https://github.com/Danp2/WebDriver/releases/tag/0.2.0.6 In the screenshot attached, only 2 Source Code files are shown, there's no download for "0.2.0.6.zip"? I noticed the file wd_demo.au3 (that you asked me to read) is listed in there. I was so lost, thinking...something's definitely missing. Now I know the reason. Edited April 19, 2020 by Purity8 Link to comment Share on other sites More sharing options...
Danp2 Posted April 19, 2020 Author Share Posted April 19, 2020 @Purity8 Download the zip file (first link) and then extract it's contents. There are three different .au3 files contained in the zip file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Purity8 Posted April 19, 2020 Share Posted April 19, 2020 The source code one? Link to comment Share on other sites More sharing options...
Danp2 Posted April 19, 2020 Author Share Posted April 19, 2020 Yes Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Purity8 Posted April 19, 2020 Share Posted April 19, 2020 Got it. Thanks. That's odd I wasn't able to find it first time around. Link to comment Share on other sites More sharing options...
HJL Posted April 19, 2020 Share Posted April 19, 2020 (edited) Hi Dan, I have been searching for a while and didn't find anything: how to set the size and position of a window with _WD_Window($sSession, 'rect', $sOption) ? I tried several forms f.e. like $sOption = ' "x":84,"y":40,"width":1000,"height":700 ' but no luck. Edited April 19, 2020 by HJL Link to comment Share on other sites More sharing options...
Danp2 Posted April 19, 2020 Author Share Posted April 19, 2020 @HJL When you retrieve the window size using _WD_Window, the results from the Webdriver look like this -- {"x":3,"y":3,"width":1295,"height":1077} You would need to use the same format when changing the window size -- _WD_Window($sSession, 'rect', '{"x":30,"y":30,"width":100,"height":100}') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts