我們有一臺Ubuntu服務器,我們用它來運行Chrome和Firefox(我安裝ChromeDriver)的Selenium測試,我也想在我的Windows 10計算機上本地運行測試。我希望兩臺計算機的Python代碼保持一致。但我沒有找到如何在Windows 10上安裝ChromeDriver?我沒有在文檔 [1,2]上找到它。如何在Windows 10上安裝ChromeDriver並使用Chrome運行Selenium測試?
這裏是運行Chrome的測試代碼:
import unittest
from selenium import webdriver
class BaseSeleniumTestCase(unittest.TestCase):
...
...
...
...
def start_selenium_webdriver(self, chrome_options=None):
...
self.driver = webdriver.Chrome(chrome_options=chrome_options)
...
我還發現How to run Selenium WebDriver test cases in Chrome?但它似乎沒有在Python
(無需編程語言標記,它是什麼?) 更新#1:我在https://sites.google.com/a/chromium.org/chromedriver/getting-started中發現了一些Python代碼,但是如果我想爲兩臺計算機保留相同的Python代碼,我會在哪裏將文件放在Windows 10中?
更新#2:我下載並把chromedriver.exe
在C:\Windows
和它的工作,但我沒有看到它在任何地方記錄。
這是最新的Chrome更新後仍然適合你嗎?我的測試瀏覽器現在在一個小的命令提示符窗口旁邊出現空白。 –
@AlexR是的,它的工作原理。 – Uri