nooneclose Posted September 9, 2019 Share Posted September 9, 2019 @Danp2 I got it to work! Thank you for all your help! You have been so patient with me. I added: _WD_Window($sSession, "window") Local $logOut = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@alt='Sign Out ALT+S']") Sleep(2000) after the webpage navigated and it clicked on logout! Link to comment Share on other sites More sharing options...
Danp2 Posted September 9, 2019 Author Share Posted September 9, 2019 (edited) @nooneclose That was to get Edge to launch correctly. 2 hours ago, nooneclose said: my only problem now is that the logout click isn't working. I think it is due to once sign-in is clicked a new page is displayed and I have to re-attach the _wd_window or something so it knows where the logout image is located. No idea. You'll need to provide more info if you want further assistance. Edit: I see that you've got it working. Edited September 9, 2019 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 10, 2019 Author Share Posted September 10, 2019 19 hours ago, Danp2 said: @nooneclose No, I believe the issue is that the webdriver app (ChromeDriver in this case) isn't properly handling these commands. Turns out that I needed to include a body as part of the post request being sent to the webdriver. This will be fixed in the next release, but you can work around it in the mean time by passing the optional 3rd parameter, like this -- _WD_Window($sSession, "Minimize", "{}") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mohanjackie Posted September 10, 2019 Share Posted September 10, 2019 I am stuck with this loop feature, I am planing on looping the script like when the radio button is found on this Website that it needs to space bar once and click on any of the radio button, but the problem is hopw to set it on loop so it keeps searching for that radio button, and space bar and click on loop Link to comment Share on other sites More sharing options...
Danp2 Posted September 10, 2019 Author Share Posted September 10, 2019 @mohanjackie No idea what you're trying to say here. Perhaps you could come back with a better description of the real problem (ie: the actual website you are trying to automate) and show us what you've tried thus far. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
OneSolution Posted September 11, 2019 Share Posted September 11, 2019 On 9/8/2019 at 3:01 PM, Danp2 said: Check out _WD_FindElement's $lMultiple parameter. Setting it the True will give you a returned array of matching elements. You could also try the following to retrieve the 2nd instance -- _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[contains(text(),'10:00 am')][2]") Changing the _WD_FindElement $IMultiple didn't work for me. But! I was very successful with the 2nd instance method! Thank you!! Link to comment Share on other sites More sharing options...
nooneclose Posted September 12, 2019 Share Posted September 12, 2019 (edited) How do I get the value of an input field in WebDriver? I tried this: ; Get Work Order Number Local $eWorkNumber = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='mad3161b5-tb']") ConsoleWrite(@CRLF & @CRLF & "Work Order Number: " & $eWorkNumber & @CRLF & @CRLF) _WD_ElementAction($sSession, $eWorkNumber, 'property') _WD_ElementAction($sSession, $eWorkNumber, 'text') ConsoleWrite(@CRLF & @CRLF & "Work Order Number: " & $eWorkNumber & @CRLF & @CRLF) Sleep(500) but it doesn't get me the number value it gets me some random string of numbers and letters. (maybe it gets me the reference to that input box?) It should get me "1234" but it gets me "0005e6cf-da10-4c49-8747-448deb99f78a" Edited September 12, 2019 by nooneclose Link to comment Share on other sites More sharing options...
Danp2 Posted September 12, 2019 Author Share Posted September 12, 2019 @nooneclose The simple answer is that you're doing it wrong. 🙄 Look at the last section of the DemoElements function in wd_demo.au3 for the proper technique. nooneclose 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
nooneclose Posted September 12, 2019 Share Posted September 12, 2019 🤣 @Danp2 Thank you. I have no idea how I missed that it works now. Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2019 Author Share Posted September 20, 2019 2 hours ago, DavFount said: $_WD_DEBUG = false I assume you're using the latest UDF release. This syntax is old, so you should look into updating that. Otherwise looks good to me. Can't say that I've experienced the issue you described. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kiwiman Posted September 20, 2019 Share Posted September 20, 2019 Hi I need some help with WD_core_au3 webdriver you have made. for accessing a admin page for googles studio.youtube.com it sends the URL for the dashboard where I scrape some data on page.. but only if manually login and enter the annoying captcha thing with random word. it dont seem to open the normal chrome or firefox but opens another browser with bar saying it was opened by webdriver so its like a new session/clear login cookies each time. is there a way to get it to login automatically even if you send ID/password the captcha thing will halted it autoBot detection, and no way to bypass that. why can't it use the normal FF/Chrone where the login cookie is not lost. (hope that makes sense) Ive reading through forum and searching but not found a answer if there is one to this problem. sorry if it has been answered and missed it.. please point me to solution if so. cheers Paul windows 10, Latest nonBeta Chrome 77.x Func YTElements() _WD_Navigate($sSession, "https://studio.youtube.com/channel/replacechannelname") sleep(5000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@class='metric-value-big style-scope ytcd-channel-facts-item']") $sYTSubsText = _WD_ElementAction($sSession, $sElement,'text') ConsoleWrite('YTSubs = ' & $sYTSubsText & @CRLF) EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2019 Author Share Posted September 20, 2019 @kiwiman Unless you specify otherwise, the webdriver always launches with a new, temporary profile. You have a couple of options -- Manually launch Firefox using the "-marionette" argument and then connect to it with the correct webdriver options. This is what I regularly use -- _WD_Option('Driver', 'C:\path\to\webdriver\executable\geckodriver.exe') _WD_Option('DriverParams', '--log trace --connect-existing --marionette-port 2828') _WD_Option('Port', 4444) $_WD_DEBUG = $_WD_DEBUG_Info $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) There are ways to specify the profile for the browser to utilize when launched via the webdriver. I haven't been using this method, but I believe it has come up previously in this forum on multiple occasions. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kiwiman Posted September 20, 2019 Share Posted September 20, 2019 thanks mate, will that work with chrome too? as chrome seems faster on win 10 you mean using the -p profilenumber after the exe for option 2? i have a play with firefox meantime to see if I can get something working atleast cheers Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2019 Author Share Posted September 20, 2019 @kiwiman Try searching the forum for the phrase "user-data-dir", which should give you a listing of the prior discussions I mentioned earlier. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kiwiman Posted September 20, 2019 Share Posted September 20, 2019 (edited) thanks.. looks like I still got some self learning to do.. search and reading to do to figure it out.. Im using firefox quantum 68.. so not sure if version matters. but it will launch firefox from gecko ok and load a page with new profile I tried the firefox mod.. it dont launch a new firefox but I clearly missing how to launch an existing firefox with a existing profile with marionetter turned on thought commandline --marionette for the launch but I guess never that simple "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -marionette-port 2828 ----- OK my win User is Paul so I assume mean try this in the launcher for chrome $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\Paul\\AppData\\Local\\Google\\Chrome\\User Data"] }}}}' again I need to find out to launch chrome initial with marionette Edited September 20, 2019 by kiwiman Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2019 Author Share Posted September 20, 2019 32 minutes ago, kiwiman said: I tried the firefox mod.. it dont launch a new firefox but I clearly missing how to launch an existing firefox with a existing profile with marionetter turned on I manually launch it using Start > Run with the command "firefox.exe -marionette". 34 minutes ago, kiwiman said: again I need to find out to launch chrome initial with marionette Marionette is only applicable to Firefox. AFAIK, you can't attach to an existing Chrome instance with the webdriver. You will launch a new Chrome instance with _WD_CreateSession. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kiwiman Posted September 20, 2019 Share Posted September 20, 2019 (edited) Yes mate, I tried this C:\Program Files (x86)\Mozilla Firefox\firefox.exe -marionette as well and still the autoit is not sending the webpage to load I do have pinned tabs on default firefox 68 do I have to install marionette or is it built in? how can I check FF has it? im 32bit on win 10 for FF.. maybe it only works for 64bit firefox? anyhow coding all day.. 5am bed time.. beats me.. I cant see what Im missing. Edited September 20, 2019 by kiwiman Link to comment Share on other sites More sharing options...
Danp2 Posted September 20, 2019 Author Share Posted September 20, 2019 If FF is running under remote control (ie: marionette is active), you should see the "robot" icon next to the URL (see image). I'm using FF Quantum 69, but this worked for me on prior versions as well. 1 hour ago, kiwiman said: Yes mate, I tried this C:\Program Files (x86)\Mozilla Firefox\firefox.exe -marionette Did this launch the browser? If not, did you try enclosing the full file path in double quotes? Also, make sure that there aren't any other instances of FF running before you issue this command. Finally, you may want to review this post for other troubleshooting techniques / possible solutions. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kiwiman Posted September 21, 2019 Share Posted September 21, 2019 (edited) Again thanks for that.. (1) yes it has that robot icon so that confirms its works in v68 32bit then? (2)is your 64bit or 32bit.. maybe makes a difference (3) Im wondering if had to be also run as admin rather then pseudo admin mode win 10 Now before I played with the webdriver options for browser both work in new session new profile (4) however chromedriver.exe open a dos type command window in max size.. but the geckodriver.exe (32bit one) never did is there a way to show and hide those command windows (5) also at some stage I want the browsers no to open up over stuff.. I guess compat option run minimize solves that part -----I had debug false turned it back on to check and got this webdriver exception... below? "C:\Users\Paul\Documents\SubsChromeScraper1.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop _WDStartup: OS: WIN_10 WIN32_NT 17763 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.1.0.21 _WDStartup: Driver: 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={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}} __WD_Post: StatusCode=0; ResponseText=0 __WD_Post ==> Send / Recv error _WD_CreateSession: 0 _WD_CreateSession ==> Webdriver Exception: HTTP status = 0 +>15:10:21 AutoIt3.exe ended.rc:0 +>15:10:21 AutoIt3Wrapper Finished. >Exit code: 0 Time: 4.7 I copied it to windows so its searchable also added path.. maybe the location is a issue Func SetupGecko() _WD_Option('Driver', 'C:\windows\geckodriver.exe') ;_WD_Option('DriverParams', '--log trace') _WD_Option('DriverParams', '--log trace --connect-existing --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc Edited September 21, 2019 by kiwiman Link to comment Share on other sites More sharing options...
kiwiman Posted September 21, 2019 Share Posted September 21, 2019 (edited) OK I got it going.. but only if I remove the --connect-existing the webdriver window black opens with commands going in it.. its maximized.. (anyway to min that to tool bar?) but what it does it opens a second FF window but sends commands to a new tab on the already opened Firefox... where the cookies are and it dont ask for login.. auto logs in.. so having 32bit driver in windows path is fine. why connect existing throws exception I dont know. if I close session it dont close the new open window but the pre-opened firefox.. so 2 steps forward 1 step back..\ I think im going to try installing 64bit 69 ver.. and see if solves it.. I see if I can keep 32bit or use either at same time. ========================= Update I have confirmed its a BUG in 32bit version or might be a add-on like adblocker?.. I install 64bit to programs the 64bit location so made a new profile keeping my old 32bit FF working and logged into google to set login cookie and ran the script with connect existing and it worked.. HOWEVER a new BUG.. google page wont show if FF is minimized to start with so it wont scrape page. they must of done it on purpose.. so now I have to force maximize.. so looking how to do that.. ps also now the geckodriver command window its not popping up its staying hidden by default kinda weird the 32bit one wasnt. Edited September 21, 2019 by kiwiman Link to comment Share on other sites More sharing options...
Recommended Posts