Python 2.7 使用Pytest_mozwebqa更改chrome中的默认下载位置

Python 2.7 使用Pytest_mozwebqa更改chrome中的默认下载位置,python-2.7,selenium-webdriver,Python 2.7,Selenium Webdriver,任何人都可以帮助我如何更改selenium中的chrome设置,使用pytest将文件下载到所需位置。 在eclipse的运行配置中,我应该向下面的命令添加什么来更改下载路径 --baseurl=''--driver=chrome在Python本身中,它应该是: chromeOptions = webdriver.ChromeOptions() chromeOptions.add_experimental_option("prefs", {"download.default_directory"

任何人都可以帮助我如何更改selenium中的chrome设置,使用pytest将文件下载到所需位置。 在eclipse的运行配置中,我应该向下面的命令添加什么来更改下载路径


--baseurl=''--driver=chrome

在Python本身中,它应该是:

chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("prefs", {"download.default_directory": "some/path", "download.directory_upgrade": true})
driver = webdriver.Chrome(executable_path="the/path/to/the/driver.exe", chrome_options=chromeOptions)
相关的:

如果我正确理解“Pytest_mozwebqa”的工作原理,您可以尝试添加以下命令行:

--chromeopts='{"prefs":{"download.default_directory":"some/path","download.directory_upgrade":true}}'

在Python本身中,它将是:

chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("prefs", {"download.default_directory": "some/path", "download.directory_upgrade": true})
driver = webdriver.Chrome(executable_path="the/path/to/the/driver.exe", chrome_options=chromeOptions)
相关的:

如果我正确理解“Pytest_mozwebqa”的工作原理,您可以尝试添加以下命令行:

--chromeopts='{"prefs":{"download.default_directory":"some/path","download.directory_upgrade":true}}'

谢谢Cherry,但是如果我使用上面的命令行,我会得到错误:platform win32--python2.7.9--pytest-2.4.1错误:file not found:c:/ler,plugins:mozwebqa,xdist。这就是我如何编写命令--baseurl=--chromeopts='{“prefs”:{“download.default\u directory”:“c:/ler”,“download.directory\u upgrade”:true}}'--driver=chrome-k test\u nid\u config\u manage“。请帮助尝试删除
chromeopts
参数中的空格,并尝试使用
c:\\ler
而不是
c:/ler
我按u所说的那样尝试,但现在它给我的值有误。”。“ValueError:无法解码JSON对象”根据您的shell,您甚至可能需要4个反斜杠而不是2个。如果它仍然不起作用,试着回到你最初使用的正斜杠(但仍然没有空格),你是否仍然得到错误,或者它只是不适合你?(运行但仍在旧文件夹中下载)谢谢,但是如果我使用上面的命令行,我会得到错误:平台win32--Python 2.7.9--pytest-2.4.1错误:未找到文件:c:/ler,插件:mozwebqa,xdist。这就是我如何编写命令--baseurl=--chromeopts='{“prefs”:{“download.default\u directory”:“c:/ler”,“download.directory\u upgrade”:true}}'--driver=chrome-k test\u nid\u config\u manage“。请帮助尝试删除
chromeopts
参数中的空格,并尝试使用
c:\\ler
而不是
c:/ler
我按u所说的那样尝试,但现在它给我的值有误。”。“ValueError:无法解码JSON对象”根据您的shell,您甚至可能需要4个反斜杠而不是2个。如果它仍然不起作用,试着回到你最初使用的正斜杠(但仍然没有空格),你是否仍然得到错误,或者它只是不适合你?(运行但仍在旧文件夹中下载)