简体   繁体   English

python中的Selenium - 打开testprogamm后立即关闭浏览器

[英]Selenium in python - Browser closing immediately after open testprogamm

As soon as I run my program, google opens (so far so good) but this window closes immediately after the program has run.一旦我运行我的程序,谷歌就会打开(到目前为止一切都很好)但是这个窗口在程序运行后立即关闭。 I already installed the chromdriver (also matches the version of the search engine) and put it in the script folder in Python.我已经安装了 chromdriver(也匹配搜索引擎的版本),并把它放在 Python 中的脚本文件夹中。 Can someone help me?有人能帮我吗?

Here is my Code:这是我的代码:

from selenium import webdriver

driver = webdriver.Chrome()

driver.get("http://google.com")

You need to specify an excecutable path for a chrome driver to be able to open a browser.您需要为 chrome 驱动程序指定一个可执行路径才能打开浏览器。 download a driver based on your browser in your case it's Chrome from here: https://chromedriver.chromium.org/downloads根据您的浏览器下载驱动程序,在您的情况下是 Chrome: https ://chromedriver.chromium.org/downloads

then driver = webdriver.Chrome(here you have to write the path of the driver),you can put it wherever you want.然后driver = webdriver.Chrome(这里要写驱动的路径),随便放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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