简体   繁体   中英

Python Selenium Remote Webdriver(Chrome Webdriver via Selenium Grid), created but does not open browser

I have the following setup:

  1. A Selenium server hub running at " http://localhost:hubPortNum " (a service with the Jar file selenium-server-standalone-3.141.5.jar with parameter -role hub).
  2. A Selenium Node at running " http://localhost:nodePortNum ' (the service with Jar file with parameters: -Dwebdriver.chrome.driver=ChromeWebdriverPath -role node -port :nodePortNum).
  3. I checked the URL for the hub and node instances to be sure they are working.

Whenever I try to create Remote Webdriver via Python script:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

desiredCapabilities = DesiredCapabilities.CHROME.copy()
chromeOptionsRemote = webdriver.ChromeOptions()
chromeOptionsRemote.add_argument("--start-maximized")
chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")

initRemoteDriver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://127.0.0.1:<nodePortNum>/wd/hub', desired_capabilities=desiredCapabilities)
print(initRemoteDriver.current_url)

The last line does print the current URL(which is "data:,"), that means Webdriver is created.

But the browser does not open on my local machine, that is it is running in the background and I don't know how to make it visible although it has worked in the past.

The troubleshooting steps I have made:

  1. Reinstall latest selenium python package.
  2. Re-Download latest Selenium server jar file.
  3. Updating chrome.
  4. adding chromeOptionsRemote.add_argument("--no-sandbox")
  5. Making sure local Webdriver does open: That is the line:

     self.localDriver = webdriver.Chrome(options=chromeOptionsLocal, desired_capabilities=desiredCapabilities) 

    does open the browser locally(the Chromedriver is in the path).

After I made these troubleshooting steps, I have tried the same configuration on a remote server and got the same result(browser not visible), so I think this is probably by design.

what configuration should I create for the browser to be visible?

Any help would be appreciated.

I was running the jar file by Always-Up: https://www.coretechnologies.com/products/AlwaysUp/

The problem was related to session 0 isolation: https://stackoverflow.com/a/26752251/2710840

in order to not run the application under session 0, I have enabled the Autologon feature: 在此处输入图片说明

defined the user under the application run as my user: 在此处输入图片说明

and executed the application from the context menu with the option to: "restart in this session"

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM