Developers Jos Posted May 12, 2020 Developers Share Posted May 12, 2020 5 hours ago, hoangvu0905 said: Sorry to bother you again. I use firefox to reopen the existing profile. However this firefox does not save my previous used browser history. Can you help me Thank you very much. Please use this Support thread for your questions. Thanks Danp2 and hoangvu0905 1 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Danp2 Posted May 12, 2020 Author Share Posted May 12, 2020 5 hours ago, hoangvu0905 said: I use firefox to reopen the existing profile. However this firefox does not save my previous used browser history. Can you help me From your description, it sounds like you aren't doing it correctly because I believe the browser history would be present if the correct profile is used. Enter "about:support" as a URL to go to the troubleshooting page, which will show you the current profile in use. Compare this information for browser instances launched manually vs with the webdriver. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sarge Posted May 12, 2020 Share Posted May 12, 2020 @Danp2Thanks for your answers, but the question remains 😞 When I make a request like: $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='/office_online/']", Default, True) _ArrayDisplay($aElements) I get the array values: Row0 47fe4e84-786e-44d1-b3bc-44e2a72df893 Row1 47fe45bk-5466-44d1-9879-tgedfghgf785 What this means, I do not know, but at least on the page the query finds this entry. But I need to get in the array a value like Row0 office_online and I make a request: $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='/*/']", Default, True) _ArrayDisplay($aElements) However, he is not looking for anything Even if I put * or *. *😞 How can I get what I need if the page has a code of the form: ... <div class="username"> <a href="/office_online/"> office_online</a> </div> .... ??? Link to comment Share on other sites More sharing options...
Danp2 Posted May 12, 2020 Author Share Posted May 12, 2020 38 minutes ago, sarge said: When I make a request like <snip> I get the array values <snip> What this means, I do not know, These are the element id's of the elements that matched your given criteria. Now go back and read me earlier response about how to process them further to get the desired property / attribute from each one. You'll need to make some adjustments since your criteria has changed. P.S. Your requirements are certainly unique. Can you share more details on what your end goal is and what website is involved? sarge 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
hoangvu0905 Posted May 13, 2020 Share Posted May 13, 2020 Sorry for the wrong comment topic. Following your instructions, I went to "about: support". And I realized that Profile is automatically created (it is at% Temp%) without activating the cache (the history is in the browser cache). I added "about: config" such an index and it worked. Thank Danp2. Link to comment Share on other sites More sharing options...
sarge Posted May 13, 2020 Share Posted May 13, 2020 @Danp2Hello, Thank you for your comments! After reading them more carefully and examining the desired page, I found a working configuration: $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='cell']", Default, True) $sSource = _WD_ElementAction($sSession, $aElements[Random(0,UBound($aElements)-1,1)], "Attribute", "href") _WD_Navigate($sSession, $sSource) Or, to implement a mouse click, you can implement the following: $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='cell']", Default, True) _WD_ElementAction($sSession, $aElements[Random(0,UBound($aElements)-1,1)], 'click') And then bring it all into a cycle according to your taste... Thanks again for your tips! Without them, I would not have done anything. And I apologize for future questions :-) P.S. This is how a random selection of pictures is implemented on a project similar to wallpapers.com Link to comment Share on other sites More sharing options...
PoojaKrishna Posted May 15, 2020 Share Posted May 15, 2020 Hi, I am trying to push geckodriver's output to a .log file. But I couldn't find any geckodriver.log file in the script folder after execution. Am I missing any parameters in the setup method? Please help. Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') ;_WD_Option("DriverParams", '-vv >' & @ScriptDir & '\geckodriver.log') ;_WD_Option('DriverParams', '--log trace --marionette-port 3687') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted May 15, 2020 Author Share Posted May 15, 2020 @PoojaKrishna Not something that I've needed to do with geckodriver, but I think you have the right idea with setting "DriverParams" with the appropriate file redirection. Did you try it like this, which should handle a path with spaces in it? _WD_Option('DriverParams', '--log trace > "' & @ScriptDir & '\geckodriver.log"') P.S. You post was moved to this support thread because the other thread is intended for UDF development discussions. Please post your future support questions here Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
PoojaKrishna Posted May 15, 2020 Share Posted May 15, 2020 Just tried and failed. Copying the console out. _WDStartup: OS: WIN_10 WIN32_NT 17763 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.2.0.4 _WDStartup: WinHTTP: 1.6.4.1 _WDStartup: Driver: geckodriver.exe _WDStartup: Params: --log trace > "D:\Pooja Projects\Tim\geckodriver.log" _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 Link to comment Share on other sites More sharing options...
Danp2 Posted May 15, 2020 Author Share Posted May 15, 2020 @PoojaKrishna Your UDFs are out of date (both Webdriver and WinHTTP). Please update with latest versions from Github and then try again. P.S. There hasn't been an official release of WinHTTP in quite some time, but you can grab the latest source from here Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
PoojaKrishna Posted May 15, 2020 Share Posted May 15, 2020 All files updated, but not working with: Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') ;_WD_Option('DriverParams', '--log trace') _WD_Option('DriverParams', '--log trace > "' & @ScriptDir & '\geckodriver.log"') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' EndFunc _WD_IsLatestRelease: True _WD_IsLatestRelease ==> Success _WDStartup: OS: WIN_10 WIN32_NT 17763 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.2.0.9 (Up to date) _WDStartup: WinHTTP: 1.6.4.2 _WDStartup: Driver: geckodriver.exe _WDStartup: Params: --log trace > "D:\Pooja Projects\Tim\geckodriver.log" _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 __WD_Delete: URL=HTTP://127.0.0.1:4444/session/ __WD_Delete: StatusCode=0; ResponseText=0... __WD_Delete ==> Webdriver Exception _WD_DeleteSession: 0 _WD_DeleteSession ==> Webdriver Exception: HTTP status = 0 Link to comment Share on other sites More sharing options...
Danp2 Posted May 15, 2020 Author Share Posted May 15, 2020 With these settings, the Geckodriver console opens and then immediately closes. Not sure of the cause, and not unable to look into it further ATM. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sarge Posted May 16, 2020 Share Posted May 16, 2020 @Danp2Hello, I got a system question. Most of the processing in the programs looks like this: For i = 1 to 50 _WD_Navigate($sSession, "https://test.com") Sleep(1500) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='nav_list']") Sleep(500) ....etc.... Next Accordingly, time is lost until each session responds to the cycle and proceeds to the next step. And if the sessions are 50, 100, 500? It takes a long time before the cycle is completed! Is there a way to implement multiprocessing in a program? That is, each browser session starts to execute the command immediately, without waiting for the previous one? Link to comment Share on other sites More sharing options...
Danp2 Posted May 16, 2020 Author Share Posted May 16, 2020 @sarge Maybe I'm just being extra dense in my old age, but I'm having difficulty understanding the issue -- Which commands are causing the slowdown? Have you tried controlling multiple tabs by switching between them with _WD_Window or _WD_Attach? If you are trying to reduce run times, why throw in the extra Sleep commands? seadoggie01 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sarge Posted May 16, 2020 Share Posted May 16, 2020 @Danp2I’ll try to clarify. I need to send a certain function to all sessions at once. Not busting in a loop, but at the same time! For this function to be performed by each session, immediately .. Link to comment Share on other sites More sharing options...
Danp2 Posted May 16, 2020 Author Share Posted May 16, 2020 Maybe have a single "host" script that communicates with a bunch of "worker" scripts. Each worker script could control it's own browser session. Check out this UDF -- sarge 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sarge Posted May 18, 2020 Share Posted May 18, 2020 @Danp2Hello, Some more simple questions came up. I’m probably too careless, but I can’t understand why I can’t insert a variable element search string: $sURL = GUICtrlRead($URL) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='&$sURL&']") _WD_ElementAction($sSession, $sElement, 'click') Another attempt with this design: $sURL = GUICtrlRead($URL) _WD_LinkClickByText($sSession, $sURL) Also gives nothing, no matter what text I enter into the variable $sURL... Do not tell me where I'm wrong? And whether the functions still work: _WD_MoveMouseTo($sSession,$sElem), _WD_SetFocus($sSession,$sElem) ?? Link to comment Share on other sites More sharing options...
Danp2 Posted May 18, 2020 Author Share Posted May 18, 2020 8 minutes ago, sarge said: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='&$sURL&']") Write the result to the console and you should see the issue, like this -- ConsoleWrite("//a[@href='&$sURL&']" & @crlf) Quote _WD_LinkClickByText($sSession, $sURL) The function is _WD_LinkClickByText, so it's not going to work with the URL because you generally won't find the URL in the text attribute of a link. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
sarge Posted May 18, 2020 Share Posted May 18, 2020 Yes, with this request the variable is not converted, and shows in console: $sURL = office_online $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='&$sURL&']") ConsoleWrite("//a[@href='&$sURL&']" & @crlf) .......................................... //a[@href='&$sURL&' But when I insert a direct link: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='office_online']") Everything works fine... The question was, is it even possible to insert a variable into this line? Link to comment Share on other sites More sharing options...
Danp2 Posted May 19, 2020 Author Share Posted May 19, 2020 (edited) Yes, it's possible if you do it correctly. Currently, there isn't any concatenation occurring because you don't have words quotes in the correct location. I'm sure you can solve this yourself if you make an effort. 😉 Edited May 19, 2020 by Danp2 typo Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts