Dhanaraju Posted July 1, 2020 Share Posted July 1, 2020 Hi Requirement: We are trying to use Chromedriver.exe with Webdriver to open sessions across user login sessions. Basically we are creating EXE which can open chrome and do some activity. Now multiple users can login and launch this EXE. Problem: Issue is every time new launch happens, __WD_CloseDriver in _WD_Startup method closes the chromedriver. If 1st session is not done and 2nd session starts, then 1st one will abort in the middle. Tried solutions: We can start chromedriver server at port 9515 and then keep creating new launches but all the new chrome browsers are being started in same windows session where the first chromedriver started instead of windows session where my exe is being executed. Temp solution I have is to call _WD_Shutdown after my activity and till ChromeDriver process is killed all new sessions will have to wait as it is one at a time. But i really want to allow simultaneous launches, can someone please guide if you have any idea. Link to comment Share on other sites More sharing options...
beldeamon Posted July 1, 2020 Share Posted July 1, 2020 Hello ..first post for me. I have been tinkering with the webdriver for a while now and had an automated script in place to download reports from AWS Quicksights on an hourly basis. All was working fine until i dumped more data into AWS and added another tab into a page. After finding the element within the code, i now get a "could not be scrolled into view" error when i try to click. Strangely, it works for all tabs except one (which has a much larger list of variables) Any ideas how to get round this ?? I did seem some notes on the selenium about using JS to resolve but not sure how to even achieve this. Thanks for any pointers <<CODE>> _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'visual-view-header')]",1000,120000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//div[contains(@class,'visual-view-header')]") _WD_ElementAction($sSession, $sElement, 'click') _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@data-automation-id='analysis_visual_dropdown_menu_button']",1000, 120000) <<ERROR>> __WD_Post: URL=HTTP://127.0.0.1:4444/session/91c341a5-b985-4e72-aaa9-49a7c40b7f8d/element; $sData={"using":"xpath","value":"//div[contains(@class,'visual-view-header')]"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"fc61436a-d4c1-4677-b59c-5619ccd7bd70"}} _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"fc61436a-d4c1-4677-b59c-5619ccd7bd70"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:4444/session/91c341a5-b985-4e72-aaa9-49a7c40b7f8d/element; $sData={"using":"xpath","value":"//div[contains(@class,'visual-view-header')]"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"fc61436a-d4c1-4677-b59c-5619ccd7bd70"}} _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"fc61436a-d4c1-4677-b59c-5619ccd7bd70"}} __WD_Post: URL=HTTP://127.0.0.1:4444/session/91c341a5-b985-4e72-aaa9-49a7c40b7f8d/element/fc61436a-d4c1-4677-b59c-5619ccd7bd70/click; $sData={"id":"fc61436a-d4c1-4677-b59c-5619ccd7bd70"} __WD_Post: StatusCode=400; ResponseText={"value":{"error":"element not interactable","message":"Element <div class=\"visual-view-header no-visual-title\"> could not be scrolled into view","stacktrace":"WebDriverError@chrome://marionette/content/error.js:175:5\nElementNotInteractableError@chrome://marionette/content/error.js:285:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:159:11\ninteraction.clickElement@chrome://marionette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1344:28\nnavigate/<@chrome://marionette/content/listener.js:446:13\nnavigate@chrome://marionette/content/listener.js:447:7\nclickElement@chrome://marionette/content/listener.js:1342:18\n"}} _WD_ElementAction: {"value":{"error":"element not interactable","message":"Element <div class=\"visual-view-header no-v... Link to comment Share on other sites More sharing options...
Danp2 Posted July 1, 2020 Author Share Posted July 1, 2020 @Dhanaraju Add the following line at the beginning of your script to prevent the automatic closure of an existng webdriver console -- _WD_Option('DriverClose', False) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted July 1, 2020 Author Share Posted July 1, 2020 @beldeamon Have you checked to see if there are multiple Div elements with this same class name? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
beldeamon Posted July 2, 2020 Share Posted July 2, 2020 Hi Danp - Thank for replying Basically i was selecting a line above the grid which was working on all but one grid, which had a large amount of columns and gave back a "could not be scrolled into view" error. I debugged some more and now have a working solution by always selecting column one which i know always exists on every grid, it has the same effect as clicking on the "view header" that i was using before. The below code using an "and" to correctly identify the first column, resolved my issue. Thanks again _WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//div[contains(@class,'column-name') and contains(@data-automation-id,'sn-table-column-0')]") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'column-name') and contains(@data-automation-id,'sn-table-column-0')]") _WD_ElementAction($sSession, $sElement, 'click') Link to comment Share on other sites More sharing options...
Clayson Posted July 2, 2020 Share Posted July 2, 2020 What is the correct way to close a session chrome window determined by the webdriver? There will be several chrome windows, but you can only close an open session, I use wd_shutdown to close a session and exit to close the program, but I am in life how to do with an opened chrome window! Thank you! Link to comment Share on other sites More sharing options...
Letraindusoir Posted July 2, 2020 Share Posted July 2, 2020 Quote Chrome is being controlled by automated test software How to Remove this Alert on the Chrome Browser Toolbar? I tried such as follows: "args":["disable-infobars"] _WD_Option("useAutomationExtension", False) _WD_Option("excludeSwitches", 'Collections.singletonList("enable-automation")') But it don't work.... Link to comment Share on other sites More sharing options...
CYCho Posted July 2, 2020 Share Posted July 2, 2020 (edited) @Letraindusoir You can include the following in the goog:ChromeOptions: "excludeSwitches": ["enable-automation"], "useAutomationExtension": false My current wording of $sDesiredCapabilities looks like this and it works for me. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _ '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _ '"prefs": {"credentials_enable_service": false}, "args": ["start-maximized"] }}}}' Edited July 2, 2020 by CYCho Danp2 and Letraindusoir 1 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Danp2 Posted July 2, 2020 Author Share Posted July 2, 2020 @Clayson I'm having trouble understanding your post. Are you dealing with a single instance of Chromedriver? Perhaps you could post a short snippet of code that demonstrates the issue. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ngocthang26 Posted July 3, 2020 Share Posted July 3, 2020 Hi Danp2 I have problem replace new udf _WD_Navigate($sSession, "https://r12a.github.io/app-conversion/") _WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//textarea[@id='escapedInput']") $sElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//textarea[@id='escapedInput']") _WD_ElementAction($sSession, $sElement, 'value', "Allosl woaks") This my code work old udf V0.1.0.15 When I try download new udf then code don't set value. Can you suggest help me. Thanks Link to comment Share on other sites More sharing options...
Danp2 Posted July 3, 2020 Author Share Posted July 3, 2020 @ngocthang26 Please post the results from the Scite output panel so that we can see which of these statements is possibly failing. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Letraindusoir Posted July 3, 2020 Share Posted July 3, 2020 17 hours ago, CYCho said: @Letraindusoir You can include the following in the goog:ChromeOptions: "excludeSwitches": ["enable-automation"], "useAutomationExtension": false My current wording of $sDesiredCapabilities looks like this and it works for me. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _ '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _ '"prefs": {"credentials_enable_service": false}, "args": ["start-maximized"] }}}}' Very much appreciated.Follow your advice , Now it Works good. CYCho and MarkIT 2 Link to comment Share on other sites More sharing options...
Clayson Posted July 3, 2020 Share Posted July 3, 2020 20 hours ago, Danp2 said: @Clayson I'm having trouble understanding your post. Are you dealing with a single instance of Chromedriver? Perhaps you could post a short snippet of code that demonstrates the issue. good afternoon, no, I deal with several simultaneous sessions each in a compilation. They all have the same window name so I cannot map the window and close it, I would have to close the chrome window of that specific session after finishing the code, the code it is not relevant because it is working for everything, including closing wd with wd_shutdown, closing the program with exit, just open the chrome window as it has several open and I have no way to map which one needs to close. thank's. _WD_Shutdown() Exit Link to comment Share on other sites More sharing options...
Danp2 Posted July 3, 2020 Author Share Posted July 3, 2020 @Clayson A single Chromedriver instance can support multiple webdriver sessions. If that doesn't help, then the only other suggestion is to track the PID for each instance of Chromedriver and use that to close the desired instance. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
cal Posted July 3, 2020 Share Posted July 3, 2020 I'm normally a Firefox guy but I currently use an old version that works with my scripts that are critical so no playing with a new version. Doing so broke many things and it took way to much effort to restore the old stuff even with a backup. I read that once working, the appropriate webdriver should be able to use the same code with minor tweaks so I'm looking at chrome to figure out how this stuff works so as to not touch my working Firefox stuff. (just looking at it funny has broken it a couple times so Its past time I figure the new stuff out). If I can get Chrome working I may just stay with it. Some functions have been replicated but I'm still missing some good replacement extensions. But Newer Firefox ones also lack some of the old capabilities so it might be a moot point. On to the actual issue. I just started looking into the webdriver. I've hit a snag that I'm not seeing talked about. On a whim I tried to run the same exact code at work and its fine. All I'm doing is opening chrome, moving to another page and closing. I'm just seeing how things work. When I try and open chrome using my existing profile, two of my extensions are removed by the webdriver. I've been hunting for the issue for a couple days when I tried running it at work and it does not have the same issue. Lastpass & google docs offline both get removed from my extensions at home as soon as the webdriver starts. The same code at work does not do this. While its paused before going to the next page I can check my extensions to see if they exist or not. All the other extensions are fine. Last night I was comparing my extension versions at home to work and noticed that at home it says "chrome is managed by your organization". This turned out to be fixed by removing a blank registry entry under the extension profiles. No idea what put it there. It was just a blank subfolder with no entries. Removing it removed the text. The actual extensions are all the same. That's the only difference I noticed between home and work. Since it does not have this issue at work it must be something within chrome but I have no idea where to look next. I don't fully understand what the webdrivers setup strings mean so I figured I'd ask here. Any ideas what might be causing this killing of my Lastpass & google docs at home? Here is the reproducer script. This code works fine at work but removes two extensions at home. All the rest of my extensions are untouched. A couple other lines are commented out as I looked at things. I'm hoping this is a minor issue that I've overlooked somewhere. expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities Local $sSession SetupChrome() $pid = _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://google.com") MsgBox($MB_TOPMOST, @ScriptName, 'Line ' & @ScriptLineNumber & @CRLF & '--- nav to yahoo ---') _WD_Navigate($sSession, "https://ca.yahoo.com/?p=us") MsgBox($MB_TOPMOST, @ScriptName, 'Line ' & @ScriptLineNumber & @CRLF & '--- exit ---') ;~ _WD_DeleteSession($sSession) ; error on next manual startup if used. (only if using existing profile as per below) _WD_Shutdown() Exit Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') ; default, creates a new temp profile to use. ;~ $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' ;~ $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized"] }}}}' ; start maximized. ; connect to existing profile. also faster since a profile does not need to be created. (minor) ; while it works. it also says "chrome didn't shut down correctly" next time it runs. I must be missing something. ; ... something in the exit? manual chrome close has no error on next open. ... _WD_DeleteSession related? ; ... both work and home are same issue. ; is this also killing my lastpass install... & google docs offline... only at home. works fine at work. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' EndFunc Link to comment Share on other sites More sharing options...
Sheldons_Bazinga Posted July 4, 2020 Share Posted July 4, 2020 On 6/27/2020 at 1:32 AM, Danp2 said: Please download the latest (unreleased) version of the source here and then retest. Edit: While debugging your script, I would also recommend commenting out the line where you modify $_WD_DEBUG Hi Danp2, thanks for your support. As you adviced I installed the unreleased version and commented out the $_WD_Debug Unfortunately, it did not solve the problem. I still get just the frist 3 files and a lot of errors, as pasted below. I would highly appriciate your help! expandcollapse popup>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\temp\download_test.au3" /UserParams +>17:19:10 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0) Keyboard:00000407 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0407) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\User\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\User\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:C:\temp\download_test.au3 +>17:19:11 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\download_test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_IsLatestRelease: True _WD_IsLatestRelease ==> Success _WDStartup: OS: WIN_10 WIN32_NT 18363 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.0.3 (Up to date) _WDStartup: WinHTTP: 1.6.4.2 _WDStartup: Driver: C:\temp\geckodriver.exe _WDStartup: Params: --log trace _WDStartup: Port: 4444 __WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true}} __WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"5e40115d-a28a-4c4d-b70b-fc44d3b5babe","capabilities":{"acceptInsecureCerts":f... _WD_CreateSession: {"value":{"sessionId":"5e40115d-a28a-4c4d-b70b-fc44d3b5babe","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"77.0.1","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:buildID":"20200602222727","moz:geckodriverVersion":"0.26.0","moz:headless":false,"moz:processID":384,"moz:profile":"C:\\Users\\User\\AppData\\Local\\Temp\\rust_mozprofilejRE9fo","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}} __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/window/maximize; $sData={} __WD_Post: StatusCode=200; ResponseText={"value":{"x":-8,"y":-8,"width":1936,"height":1056}}... _WD_Window: {"value":{"x":-8,"y":-8,"width":1936,"height":1056}}... __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/index.php/sample-documents-download/sample-doc-download/"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_Navigate: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_500kB.doc"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_1MB.doc"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.docx"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_500kB.docx"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 __WD_Post: URL=HTTP://127.0.0.1:4444/session/5e40115d-a28a-4c4d-b70b-fc44d3b5babe/url; $sData={"url":"https://file-examples.com/wp-content/uploads/2017/02/file-sample_1MB.docx"} __WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver... __WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver _WD_Navigate: WinHTTP request timed out before Webdriver _WD_Navigate ==> Send / Recv error: HTTP status = 0 +>17:22:33 AutoIt3.exe ended.rc:0 +>17:22:33 AutoIt3Wrapper Finished. >Exit code: 0 Time: 203.9 Link to comment Share on other sites More sharing options...
Danp2 Posted July 4, 2020 Author Share Posted July 4, 2020 @Sheldons_Bazinga If you look closely at the log, the initial _WD_Navigate succeeds, but the rest of them fail. Have you looked to see if the function _WD_DownloadFile will work for your scenario? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Clayson Posted July 6, 2020 Share Posted July 6, 2020 On 7/3/2020 at 4:42 PM, Danp2 said: @Clayson A single Chromedriver instance can support multiple webdriver sessions. If that doesn't help, then the only other suggestion is to track the PID for each instance of Chromedriver and use that to close the desired instance. Danp2, good morning! There are several compilations because each one is scheduled for a specific time. Anyway, even if it was the same session, we would have the same problem since there would be several windows open. I consider it a good option to capture the PID of the chrome window opened in the session. But the main problem is in identifying the window, because when I open the session and consequently chrome there may be another window open with the same title and the texts that I can define will be the same. This gets in the way of using WinGetProcess for example. Any suggestions on that? Thanks! Link to comment Share on other sites More sharing options...
Danp2 Posted July 6, 2020 Author Share Posted July 6, 2020 @Clayson _WD_Startup already returns the PID, so all you need to do it save it for future use. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CYCho Posted July 6, 2020 Share Posted July 6, 2020 On 7/2/2020 at 11:57 PM, Clayson said: I use wd_shutdown to close a session and exit to close the program I often use multiple webdriver sessions concurrently, but I never use WD_Shutdown to close one particular window because, if you do it, the chromedriver.exe is closed, which affects the remaining sessions. If you want to just close a window, you can do it with WD_Window($sSession, "close"). I usually have chromedriver.exe running in the background all the time even when I don't have any webdriver sessions. Danp2 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Recommended Posts