Danp2 Posted March 9, 2021 Author Posted March 9, 2021 @Paulliev _WD_ElementOptionSelect has been a part of this UDF since the V0.1.0.18 release, which is from almost a year ago. Something is wrong with your configuration, but not enough details to know the root cause. Have you checked to make sure that you don't have an old copy of the UDF lying around somewhere? Latest Webdriver UDF Release Webdriver Wiki FAQs
Paulliev Posted March 9, 2021 Posted March 9, 2021 @Danp2 Thanks for your answer! I downloaded the latest version and now I can find the function! Little bit weird because I downloaded the latest version just 2 weeks ago. I've got the following code and it gives this error: _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "/select[@name='custom_field_39021']/option[contains(text(),'Normaal (hinder)')]") Error: [1615299113.967][INFO]: [930f6be91f2eb047259bf4b232955ac6] RESPONSE ExecuteScript ERROR javascript error: arguments[0].onchange is not a function (Session info: chrome=89.0.4389.82) [1615299113.984][INFO]: [930f6be91f2eb047259bf4b232955ac6] COMMAND FindElement { "using": "xpath", "value": "/select[@name='custom_field_39021']/option[contains(text(),'Normaal (hinder)')]" I looked at all the functions, maybe I can use _WD_ElementSelectAction aswell? What's the difference between those two?
Nine Posted March 9, 2021 Posted March 9, 2021 You need // at start of the xpath Paulliev 1 “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
Danp2 Posted March 9, 2021 Author Posted March 9, 2021 12 minutes ago, Paulliev said: [1615299113.967][INFO]: [930f6be91f2eb047259bf4b232955ac6] RESPONSE ExecuteScript ERROR javascript error: arguments[0].onchange is not a function (Session info: chrome=89.0.4389.82) This looks like something coming from your code and completely unrelated to _WD_ElementOptionSelect. 🤔 _WD_ElementSelectAction may eventually allow you to choose one of the Select element's options, but currently it offers the following options -- Value - retrieve the Select element's current selection Options - retrieves the value / label attributes for the Select element's options Paulliev 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
Paulliev Posted March 9, 2021 Posted March 9, 2021 @Danp2 Thanks for your explanation. @Nine That works! I don't understand it though. I use a lot of single slashes to create my path and it works. What is the purpose of 2 slashes?
Nine Posted March 9, 2021 Posted March 9, 2021 17 minutes ago, Paulliev said: What is the purpose of 2 slashes? This is to precise it is not starting at the root of the DOM. “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
64bitfury Posted March 9, 2021 Posted March 9, 2021 Let me first preface my question with I am very new to Autoit. I have tried to find information on this myself but I havent been successful so please forgive me if this information exists and I missed it. I have put together a script that is supposed to open edge to a certain website and fill out the login form and then login. The script works if I run from SciTE but if I compile into an exe I get the error "_WD_Startup ==> General Error: Error launching web driver!" when I run the exe. I have tried including the webdriver msedgedriver.exe with the compiled script but still get the error. If I include a copy of the webdriver exe file in the same directory it works but I would really like to compile this all together in one exe for use on other computers. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_File_Add=Path To EXE\msedgedriver.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sElement, $sUNElement, $sPWElement, $sBTNElement SetupEdge() _WD_Startup() Sleep(2000) _WD_ConsoleVisible() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://website ") _WD_Window($sSession, "Maximize") $sUNElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//input[@placeholder='Email']") $sPWElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//input[@placeholder='Password']") $sBTNElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//span[@class='progress-default']") _WD_ElementAction ($sSession, $sUNElement, 'value',"username") _WD_ElementAction ($sSession, $sPWElement, 'value',"password") _WD_ElementAction ($sSession, $sBTNElement, 'click') Func SetupEdge() _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace (@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}' EndFunc
Nine Posted March 9, 2021 Posted March 9, 2021 Look at FileInstall in help file “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
64bitfury Posted March 9, 2021 Posted March 9, 2021 7 minutes ago, Nine said: Look at FileInstall in help file The help file in SciTE?
Danp2 Posted March 9, 2021 Author Posted March 9, 2021 @64bitfury IMO, a better option would be to use _WD_UpdateDriver to install msedgedriver.exe to a directory of your choice if it doesn't already exist. FrancescoDiMuro 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
NSearch Posted March 11, 2021 Posted March 11, 2021 @Danp2 I think this is a unique problem that has not been addressed before. I am trying to send a date to an input, but it is not populating the input box....so I tried to manually type the date and couldn't. When the input box is clicked at calendar pops up, which is how you're supposed to enter the date. I was able to copy and ctrl+v paste the date to the input, but that doesn't seem like a streamline solution. I even tried finding the date difference between now() and the ship date and sending left to the calendar x number of times. $ship_date_popup_exists = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="ship_date_prompt_done"]',3000,4000) If $ship_date_popup_exists = 1 Then $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,'//*[@id="shipDateInput"]') _WD_ElementAction($sSession, $sElement, 'click') _WD_ElementAction($sSession, $sElement, 'value', $oShip_Date_Popup_Format) ; MM/dd/yy ;~ $oShip_Date_Diff = _DateDiff('D', StringSplit($oShip_Date,"/")[3] & "/" & $oShip_Date_Month & "/" & $oShip_Date_Day & " 00:00:00", _NowCalc()) ;~ Send("{LEFT}",$oShip_Date_Diff) EndIf <div id="modal" class="reveal-modal" style="max-width: 860px; top: 70px; opacity: 1; visibility: visible; display: block;"><div id="modal-content"><div id="leaveTab" data-load-tab=""> <fieldset style="width:100%;"> <div class="datapoint fx_clearfix" id="city_div" style="width:40%;"> <label for="">Ship Date</label> <input type="text" name="shipdate" class="required date" id="shipDateInput"> </div> <div class="datapoint fx_clearfix" id="city_div" style="width:40%;"> <label for="">Carrier Type</label> <select name="opco" class="required" id="opcoInput"> <option value="">Select</option> <option value="Ground">Ground</option> <option value="Express">Express</option> </select> </div> <div class="buttons cf" style="margin: 10px 0;"> <div class="purple"><button class="btn-primary leave-the-tab" id="ship_date_prompt_done">Done</button></div> </div> </fieldset> </div> <a class="close-reveal-modal" id="modal_close"></a> </div></div> Calendar section <div id="calroot" style="position: absolute; top: 151px; left: 62px;"><div id="calhead"><a id="calprev"></a><div id="caltitle">March 2021</div><a id="calnext" class="caldisabled"></a></div><div id="calbody"><div id="caldays"><span>Sun</span><span>Mon</span><span>Tue</span><span>Wed</span><span>Thu</span><span>Fri</span><span>Sat</span></div><div id="calweeks"><div class="calweek"><a class="caloff" href="#28">28</a><a href="#1">1</a><a href="#2">2</a><a href="#3">3</a><a href="#4">4</a><a href="#5">5</a><a href="#6">6</a></div><div class="calweek"><a href="#7">7</a><a href="#8">8</a><a href="#9">9</a><a id="calcurrent" class="calfocus" href="#10">10</a><a class="caldisabled" href="#11">11</a><a class="caldisabled" href="#12">12</a><a class="caldisabled" href="#13">13</a></div><div class="calweek"><a class="caldisabled" href="#14">14</a><a class="caldisabled" href="#15">15</a><a class="caldisabled" href="#16">16</a><a class="caldisabled" href="#17">17</a><a class="caldisabled" href="#18">18</a><a class="caldisabled" href="#19">19</a><a class="caldisabled" href="#20">20</a></div><div class="calweek"><a class="caldisabled" href="#21">21</a><a class="caldisabled" href="#22">22</a><a class="caldisabled" href="#23">23</a><a class="caldisabled" href="#24">24</a><a class="caldisabled" href="#25">25</a><a class="caldisabled" href="#26">26</a><a class="caldisabled" href="#27">27</a></div><div class="calweek"><a class="caldisabled" href="#28">28</a><a class="caldisabled" href="#29">29</a><a class="caldisabled" href="#30">30</a><a class="caldisabled" href="#31">31</a><a class="caloff caldisabled" href="#1">1</a><a class="caloff caldisabled" href="#2">2</a><a class="caloff caldisabled" href="#3">3</a></div><div class="calweek"><a class="caloff caldisabled" href="#4">4</a><a class="caloff caldisabled" href="#5">5</a><a class="caloff caldisabled" href="#6">6</a><a class="caloff caldisabled" href="#7">7</a><a class="caloff caldisabled" href="#8">8</a><a class="caloff caldisabled" href="#9">9</a><a class="caloff caldisabled" href="#10">10</a></div></div></div></div> Thanks in advance for your help
Danp2 Posted March 11, 2021 Author Posted March 11, 2021 @NSearch Having the html doesn't really help in this situation. It would have been better to provide a URL so that we can examine the actual web page. However, I'm guessing that you are still dealing with the FedEx site, which uses jQuery. Examing the events attached to a date picker on that site will show that it's using the jQuery dateinput module. You can read more about it here. I suspect that you can manually set the date using _WD_ExecuteScript, but I haven't verified that yet. Latest Webdriver UDF Release Webdriver Wiki FAQs
NSearch Posted March 11, 2021 Posted March 11, 2021 Thanks for the response @Danp2 Please see the snippet below #include "wd_core.au3" #include "wd_helper.au3" _WD_Option('Driver', @ScriptDir & '\chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--disable-blink-features=AutomationControlled"]}}}}' $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.fedex.com/apps/onlineclaims/?locale=en_US") Sleep(1500) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,'//*[@id="trackingNumber"]') _WD_ElementAction($sSession, $sElement, 'value', '922897835504') Sleep(3000) _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//div/select/option[@value='LC']") sleep(3000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='tracking_nbr_cont_btn']") _WD_ElementAction($sSession, $sElement, 'click') MsgBox(0,"Stop","")
Danp2 Posted March 11, 2021 Author Posted March 11, 2021 26 minutes ago, NSearch said: Please see the snippet below Next time provide this type of info in the beginning. Did you read the info at the link I posted? From what I've seen, it shows how to programmatically set the date value. You just need to translate it to AutoIt / Webdriver Latest Webdriver UDF Release Webdriver Wiki FAQs
NSearch Posted March 11, 2021 Posted March 11, 2021 Thanks @Danp2 - I have been trying to make sense of the page....no luck yet. _WD_ExecuteScript($sSession, "$('#shipDateInput').dateinput('setDate', '09/20/20');") Am I on the right path?
Danp2 Posted March 11, 2021 Author Posted March 11, 2021 @NSearch I think you want something more like this -- _WD_ExecuteScript($sSession, "$('#shipDateInput').data('dateinput').setDate('2020-09-20');") However, I've tried playing with it from the browser's developer console and it doesn't work the way I would expect. Latest Webdriver UDF Release Webdriver Wiki FAQs
NSearch Posted March 11, 2021 Posted March 11, 2021 @Danp2 same problem with me -- I thought logging in may change the result, but I am not able to send the date to the input box. I will continue to try different variations of the date, but if you have any other ideas, please let me know. Thank you very much for your help!
Danp2 Posted March 11, 2021 Author Posted March 11, 2021 @NSearch Appears that the month value is zero-based, so this should work to set the date to 2/28/2021 -- _WD_ExecuteScript($sSession, "$('#shipDateInput').data('dateinput').setDate(2021, 1, 28);") Latest Webdriver UDF Release Webdriver Wiki FAQs
NSearch Posted March 11, 2021 Posted March 11, 2021 @Danp2 This is a tough one -- no luck with the code above or with _WD_ExecuteScript($sSession, "$('#shipDateInput').data('dateinput').setDate(21, 01, 28);")
Recommended Posts