51Testing软件测试论坛
标题: selenium headless无法上传文件 [打印本页]
作者: 测试积点老人 时间: 2021-12-7 09:20
标题: selenium headless无法上传文件
问题遇到的现象和发生背景selenium 在不加 headless 的时候可正常上传文件,加上 headless 之后无法运行
问题相关代码,请勿粘贴截图app = pywinauto.Desktop()
dlg = app["打开"]
driver.implicitly_wait(10)
选择文件地址输入框,点击激活dlg["Toolbar3"].click()
driver.implicitly_wait(10)
键盘输入上传文件的路径send_keys("D:\附件下载")
sleep(1)
键盘输入回车,打开该路径send_keys("{VK_RETURN}")
driver.implicitly_wait(10)
选中文件名输入框,输入文件名dlg["文件名(&N):Edit"].type_keys("配送地址.xlsx")
点击打开- driver.implicitly_wait(10)
- dlg["打开(&O)"].click_input()
- Traceback (most recent call last):
- File "D:\金投云链\venv\lib\site-packages\pywinauto\application.py", line 258, in __resolve_control
- criteria)
- File "D:\金投云链\venv\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
- raise err
- pywinauto.timings.TimeoutError
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "D:/金投云链/转脚本测试/TEts.py", line 206, in
- dlg["Toolbar3"].click()
- File "D:\金投云链\venv\lib\site-packages\pywinauto\application.py", line 379, ingetattribute
- ctrls = self.__resolve_control(self.criteria)
- File "D:\金投云链\venv\lib\site-packages\pywinauto\application.py", line 261, in __resolve_control
- raise e.original_exception
- File "D:\金投云链\venv\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
- func_val = func(*args, **kwargs)
- File "D:\金投云链\venv\lib\site-packages\pywinauto\application.py", line 203, in __get_ctrl
- dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
- File "D:\金投云链\venv\lib\site-packages\pywinauto\findwindows.py", line 84, in find_element
- elements = find_elements(**kwargs)
- File "D:\金投云链\venv\lib\site-packages\pywinauto\findwindows.py", line 305, in find_elements
- elements = findbestmatch.find_best_control_matches(best_match, wrapped_elems)
- File "D:\金投云链\venv\lib\site-packages\pywinauto\findbestmatch.py", line 536, in find_best_control_matches
- raise MatchError(items = name_control_map.keys(), tofind = search_text)
- pywinauto.findbestmatch.MatchError: Could not find '打开' in 'dict_keys(['QQTXGuiFoundation', 'QQ', 'TXGuiFoundation', '金投云链 – TEts.py PyCharmCXWindow', 'CXWindow', 'XTaskBarBtn', '金投云链 – TEts.py PyCharmXTaskBarBtn', '金投云链 – TEts.py PyCharmShell_TrayWnd', 'Shell_TrayWnd', 'SunAwtWindow', '测试沟通群等3个会话SunAwtWindow', '金投云链 – TEts.py PyCharm', 'SunAwtFrame', '金投云链 – TEts.py PyCharmSunAwtFrame', 'TXGuiFoundation0', 'TXGuiFoundation1', 'TXGuiFoundation2', '测试沟通群等3个会话TXGuiFoundation', '测试沟通群等3个会话', 'Chrome_WidgetWin_1', '(14条消息) Selenium 如何使用webdriver下载文件(chrome浏览器)_breakhl的博客-CSDN博客_webdriver下载文件 - Google Chrome', '(14条消息) Selenium 如何使用webdriver下载文件(chrome浏览器)_breakhl的博客-CSDN博客_webdriver下载文件 - Google ChromeChrome_WidgetWin_1', 'popupshadow', '微信popupshadow', '微信', 'WeChatMainWndForPC', '微信WeChatMainWndForPC', 'DummyDWMListenerWindow', 'EdgeUiInputTopWndClass', 'Internet Explorer_Hidden', 'FLUTTER_RUNNER_WIN32_WINDOW', '小牛 VPN', '小牛 VPNFLUTTER_RUNNER_WIN32_WINDOW', 'Program ManagerProgman', 'Progman', 'Program Manager', '微信SoPY_Status', 'SoPY_Status'])'
复制代码 运行结果及报错内容我的解答思路和尝试过的方法我想要达到的结果静默上传文件
作者: 海海豚 时间: 2021-12-8 09:35
路径内的\都用\\
作者: qqq911 时间: 2021-12-8 10:27
未找到对应的内容
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |