[英]Python - Open a link in new Chrome tab with Selenium WebDriver?
I would like to have a URL open in a new tab and closing itself rather than opening in front of the user as it currently stands.我希望在新选项卡中打开一个 URL 并关闭它自己,而不是像目前那样在用户面前打开。 I want it to be a discrete as possible.我希望它尽可能离散。
Here is the python code I have so far that works, but brings the window to the front:这是我到目前为止有效的python代码,但将窗口带到了前面:
def extract(self, id, pass):
chrome_dir_path = '/Users/<user>/Downloads/chromedriver'
driver = webdriver.Chrome(chrome_dir_path)
driver.implicitly_wait(5)
driver.maximize_window()
driver.get('https://<URL>')
username = driver.find_element_by_id('user')
username.send_keys(USER)
password = driver.find_element_by_id('password')
password.send_keys(PASS)
driver.find_element_by_name('remUID').click()
python_button = driver.find_element_by_class_name('button')
python_button.click()
无头运行解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.