gpt4 book ai didi

python - 文件在默认下载文件夹中持续下载

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:17 25 4
gpt4 key购买 nike

我有一个基本的设置方法:

class BaseTestCase(object):


def setUp(self):
options = webdriver.ChromeOptions()
options.add_argument("download.default_directory=C:\Users\cverma\Desktop\SOAPProject")

self.driver = webdriver.Chrome(executable_path=r"C:\chromedriver\chromedriver.exe", chrome_options=options)
self.driver.maximize_window()
self.driver.get("https://qa.smartsimpleqa.com")



def tearDown(self):
self.driver.quit()

当我在另一个测试中调用此设置方法时。我的文件一直在默认下载文件夹中下载,而我想在单击 C:\Users\cverma\Desktop\SOAPProject

后下载我的文件

最佳答案

尝试以下操作:

chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "C:\Users\cverma\Desktop\SOAPProject\"}
chromeOptions.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(executable_path=r"C:\chromedriver\chromedriver.exe", chrome_options=chromeOptions)

另请注意,如果您将错误的路径设置为“download.default_directory”值,您将不会遇到任何异常 - chromedriver 将仅使用“下载”文件夹作为默认文件夹

关于python - 文件在默认下载文件夹中持续下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41047351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com