IanN1990 Posted February 9, 2020 Share Posted February 9, 2020 @Danp2 Apologies for the delay. I was trying to troubleshoot #NoTrayIcon #AutoIt3Wrapper_Run_AU3Check=n #include ".\Includes\wd_core.au3" #include ".\Includes\wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_Info _WD_Option('Driver', @ScriptDir & '\Includes\geckodriver-v0.26.0.exe') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/Vocalink/Desktop/Firefox"]}}}}' _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit MsgBox(0, "Error", "Firefox Driver failed to load") $sSession = _WD_CreateSession($sDesiredCapabilities) If @error <> $_WD_ERROR_Success Then Exit MsgBox(0, "Error", "Firefox Driver failed to create a session") _WD_Navigate($sSession, "https://www.bbc.com") The other two args ("-kiosk", "-private") work without issue. It is -profile which is causing the problem which is odd as Firefox is loading my profile. Here is the output though it is a little sparce. _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.2.0.5 _WDStartup: WinHTTP: 1.6.4.1 _WDStartup: Driver: C:\Users\Vocalink\Desktop\09-02-2020\Includes\geckodriver-v0.26.0.exe _WDStartup: Params: _WDStartup: Port: 4444 __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/Vocalink/Desktop/Firefox"]}}}} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_CreateSession: 0 _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 Link to comment Share on other sites More sharing options...
Danp2 Posted February 9, 2020 Author Share Posted February 9, 2020 There's a newer version of WinHTTP.au3 that may fix this for you. You can copy / paste the code from here. IanN1990 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
IanN1990 Posted February 9, 2020 Share Posted February 9, 2020 Same issue Version i had previously was 1.6.4.1 (the one you linked is 1.6.4.2) Link to comment Share on other sites More sharing options...
Danp2 Posted February 9, 2020 Author Share Posted February 9, 2020 Geckodriver is unable to communicate with Firefox via Marionette. You need to examine your profile to determine the correct marionette port number. You can find this under the About:Config page. Chances are that it's 2828. Once you've got the correct number, modify your _WD_Option line like this -- _WD_Option('DriverParams', '--log trace --marionette-port 2828') replacing the "2828" as needed to match the value you found earlier. IanN1990 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
IanN1990 Posted February 9, 2020 Share Posted February 9, 2020 (edited) @Danp2 _WD_Option('DriverParams', '--log trace --marionette-port 2828') You were correct. Adding the above brought everything to life. $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-kiosk", "-private", "-profile", "C:\\Users\\IanN1990\\Desktop\\09-02-2020b\\Firefox"]}}}}' $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true, "pageLoadStrategy":"none"}}' Individually they both work flawlessly, but no matter what combination i try i am unable to merge them together. Looking at your combined attempt, i tried to work backwards by removing the firefoxoptions but i get the error below; $sDesiredCapabilities = '{"capabilities":{"alwaysMatch":{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true, "pageLoadStrategy":"none"}}}}' __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities":{"alwaysMatch":{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true, "pageLoadStrategy":"none"}}}} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"desiredCapabilities is not the name of a known capability or extension capability","stacktrace":""}} _WD_CreateSession: {"value":{"error":"invalid argument","message":"desiredCapabilities is not the name of a known capability or extension capability","stacktrace":""}} _WD_CreateSession ==> Webdriver Exception: desiredCapabilities is not the name of a known capability or extension capability Edited February 9, 2020 by IanN1990 Link to comment Share on other sites More sharing options...
Danp2 Posted February 9, 2020 Author Share Posted February 9, 2020 Yeah... you definitely don't want the "desiredCapabilities" entry inside your "alwaysMatch". Looking here, it appears that some of the options are no longer valid. This works for me -- $sDesiredCapabilities = '{"capabilities":{"alwaysMatch":{"acceptInsecureCerts":true, "pageLoadStrategy":"none", "moz:firefoxOptions": {"args": ["-kiosk", "-private", "-profile", "C:\\Users\\Username\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\Profile.Name"]}}}}' IanN1990 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
IanN1990 Posted February 10, 2020 Share Posted February 10, 2020 @Danp2 You are legend. Thank you. Your code works perfectly. Danp2 1 Link to comment Share on other sites More sharing options...
moxasya Posted February 11, 2020 Share Posted February 11, 2020 hi, i have problem to identify popup the problem start checklist i know the problem is checklist still navigate to the main window not the popup window. how to use the wd_FindElement in popup window. i'try the wd_window to handle the current popup but not working. is there anything else can fix the wd_findelement in popup. Thanks youuuu #include "wd_core.au3" #include "wd_helper.au3" 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 Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://resipicitarasawan.blogspot.com/") $PopupBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='//rcita.blogspot.com/p/resepi-checklist.html']") _WD_ElementAction($sSession, $PopupBtn, 'click') sleep(5000) $checklist = _WD_FindElement($sSession, $_WD_LOCATOR_ByXpath, "//input[@id='id']") #Element_id length is invalid _WD_ElementAction($sSession,$checklist,'value', "cake") Link to comment Share on other sites More sharing options...
Danp2 Posted February 11, 2020 Author Share Posted February 11, 2020 You didn't show us what you attempted with _WD_Window. However, I would recommend that you look at _WD_Attach Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
moxasya Posted February 11, 2020 Share Posted February 11, 2020 42 minutes ago, Danp2 said: You didn't show us what you attempted with _WD_Window. However, I would recommend that you look at _WD_Attach sorry this the code im trying but still not working. you can copy and try. _WD_Attach string parameter meaning? #include "wd_core.au3" #include "wd_helper.au3" 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 Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) ;$sHnd1 = '{"handle":"' & _WD_Window($sSession, "window") & '"}' _WD_Navigate($sSession, "https://resipicitarasawan.blogspot.com/") ;$sHnd2 = '{"handle":"' & _WD_Window($sSession, "window") & '"}' $LookupBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='//rcita.blogspot.com/p/resepi-checklist.html']") _WD_ElementAction($sSession, $LookupBtn, 'click') sleep(5000) ;_WD_Attach($sSession,$string,"RCITA - The Kanvas Blank: Resepi Checklist - Google Chrome") ;_WD_Window($sSession, "switch", $sHnd2) $checklist = _WD_FindElement($sSession, $_WD_LOCATOR_ByXpath, "//input[@id='id']") _WD_ElementAction($sSession,$checklist,'value', "cake") Link to comment Share on other sites More sharing options...
Danp2 Posted February 11, 2020 Author Share Posted February 11, 2020 This is from the function header -- ; Name ..........: _WD_Attach ; Description ...: Helper function to attach to existing browser tab ; Syntax ........: _WD_Attach($sSession, $sString[, $sMode = 'title']) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sString - String to search for ; $sMode - [optional] One of the following search modes: ; | Title (Default) ; | URL ; | HTML Your attempt should work if you remove the extra "$string,". _WD_Attach works similar to _IEAttach and supports substrings, so I would recommend this -- _WD_Attach($sSession, "Resepi Checklist") P.S. Remember that you will need to "switch back" to the original window using _WD_Window or _WD_Attach once you close the popup. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
moxasya Posted February 12, 2020 Share Posted February 12, 2020 12 hours ago, Danp2 said: This is from the function header -- ; Name ..........: _WD_Attach ; Description ...: Helper function to attach to existing browser tab ; Syntax ........: _WD_Attach($sSession, $sString[, $sMode = 'title']) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sString - String to search for ; $sMode - [optional] One of the following search modes: ; | Title (Default) ; | URL ; | HTML Your attempt should work if you remove the extra "$string,". _WD_Attach works similar to _IEAttach and supports substrings, so I would recommend this -- _WD_Attach($sSession, "Resepi Checklist") P.S. Remember that you will need to "switch back" to the original window using _WD_Window or _WD_Attach once you close the popup. Thanks for the reply, im trying both of this code but still not working, the popup not write anything. im already check the id is correct for put the value. anything else i can try? _WD_Attach($sSession,"RCITA - The Kanvas Blank: Resepi Checklist - Google Chrome") _WD_Attach($sSession,"Resepi Checklist") Error code # _WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: # _WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n Link to comment Share on other sites More sharing options...
Danp2 Posted February 12, 2020 Author Share Posted February 12, 2020 Your original code runs fine for me after adding the _WD_Attach -- #include "wd_core.au3" #include "wd_helper.au3" 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 Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://resipicitarasawan.blogspot.com/") $PopupBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='//rcita.blogspot.com/p/resepi-checklist.html']") _WD_ElementAction($sSession, $PopupBtn, 'click') sleep(5000) _WD_Attach($sSession, "Resepi Checklist") $checklist = _WD_FindElement($sSession, $_WD_LOCATOR_ByXpath, "//input[@id='id']") _WD_ElementAction($sSession,$checklist,'value', "cake") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mrPuh Posted February 13, 2020 Share Posted February 13, 2020 Hello! How I can use multithreading? For ex: script1.au3 work with one Chrome and script2.au3 work with another Chrome in parallel? Link to comment Share on other sites More sharing options...
moxasya Posted February 13, 2020 Share Posted February 13, 2020 (edited) On 2/12/2020 at 8:10 PM, Danp2 said: Your original code runs fine for me after adding the _WD_Attach -- #include "wd_core.au3" #include "wd_helper.au3" 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 Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://resipicitarasawan.blogspot.com/") $PopupBtn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='//rcita.blogspot.com/p/resepi-checklist.html']") _WD_ElementAction($sSession, $PopupBtn, 'click') sleep(5000) _WD_Attach($sSession, "Resepi Checklist") $checklist = _WD_FindElement($sSession, $_WD_LOCATOR_ByXpath, "//input[@id='id']") _WD_ElementAction($sSession,$checklist,'value', "cake") Thanks a lot. its working now !!!. just i have this problem how to click on javascript onclick like this picture. i try code like this but failed to locate. $Pick = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@onclick=\'javascript:LookupSelect(outputFields, ['3','3 ','cins'], disabledFields);TriggerParentFunction();\']") _WD_ElementAction($sSession, $Pick, 'click') Edited February 13, 2020 by moxasya Link to comment Share on other sites More sharing options...
Danp2 Posted February 13, 2020 Author Share Posted February 13, 2020 7 hours ago, mrPuh said: How I can use multithreading? For ex: script1.au3 work with one Chrome and script2.au3 work with another Chrome in parallel? You can control multiple browser instances using a single instance of Chromedriver, but not simultaneously. What have you tried as far as launching separate instances of Chromedriver for each script? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted February 13, 2020 Author Share Posted February 13, 2020 3 hours ago, moxasya said: how to click on javascript onclick Find the correct element and then click it. That's the best answer I can give with the limited into you've supplied. 😝 Did you try Google? Maybe this will help. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
P00PDOG Posted February 13, 2020 Share Posted February 13, 2020 Hi, I am migrating away from IE (to Chrome) and am having some problems adjusting to the webdriver. When I use _WD_Attach, I'm not getting that window to come to the front, I think I am using it wrong.... with the IE UDF, version it will force the window to the front. I was using an example I saw in a previous answer but that did not have "title" at the end... Next issue is finding the element, can you help me with the commands that would duplicate the below. I can navigate to the site but cant get the commands right. to find and focus on that element All I need to do is find the username element, focus, then send the value, then move to password, focus, then pass the value, then send enter. I was trying to use the demo code to do this but I am getting confused by the syntax, do you have a basic example of each function? ;$oIE = _IEAttach(" Bla Bla Bla widgets", "Title") ;Local $oSubmit = _IEGetObjByName($oIE, "a7jd$PlaceHolder1$txtLoginUsername") ;<--name of element ;_IEAction($oSubmit, "focus") ;Send($Username, 1) ;Local $oSubmit = _IEGetObjByName($oIE, "a7jd$PlaceHolder1$txtLoginPassword") ;<--name of element ;_IEAction($oSubmit, "focus") ;Send($Password, 1) ;Send("{ENTER}") Link to comment Share on other sites More sharing options...
Danp2 Posted February 13, 2020 Author Share Posted February 13, 2020 (edited) @P00PDOG You aren't doing anything wrong. Webdriver by design works without affecting the OS-level window focus. If you want a specific window to have focus, use the standard Autoit commands to perform the action. You can use the Chropath extension to help with getting the proper selector. Come back when you have some code we can review / run. Edited February 13, 2020 by Danp2 typo Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
P00PDOG Posted February 13, 2020 Share Posted February 13, 2020 Disregard my previous post. I figured it out. My appologies i'm not the best Autoit scripter for anyone else with the same issue... SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, $myURL) _WD_LoadWait($sSession) _WD_Attach($sSession, "bla bla bla website title", "title") $sElementu = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='123PlaceHolder1$txtLUsername']") ;<--name of the username element _WD_ElementAction($sSession, $sElementu, 'value', $Username) $sElementp = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='123PlaceHolder1$txtPassword']") ;<--name of the password element _WD_ElementAction($sSession, $sElementp, 'value', $Password) Send("{ENTER}") Link to comment Share on other sites More sharing options...
Recommended Posts