selenium-webdriver - browserstack_executor 操作列表在哪里?
问题描述
我发现了以下用途,但没有使用 browserstack_executor 的其他可能操作的文档:
- 文件已存在
- 获取文件内容
- 获取文件属性
- 设置会话状态
我正在寻找removeFile
或unlinkFile
或deleteFile
删除浏览器下载的文件,现在在下一个文件下载并在文件名中添加 (1) 时挡住了路。
在我的硒测试中,我正在做这样的事情:
if driver._is_remote:
action = {"action": "fileExists", "arguments": {"fileName": os.path.basename(self.filepath)}}
if driver.execute_script(f'browserstack_executor:{json.dumps(action)}'):
action = {"action": "getFileContent", "arguments": {"fileName": os.path.basename(self.filepath)}}
content = driver.execute_script(f'browserstack_executor:{json.dumps(action)}')
with open(self.filepath, "wb") as f:
f.write(base64.b64decode(content))
action = {"action": "deleteFile", "arguments": {"fileName": os.path.basename(self.filepath)}}
delete_status = driver.execute_script(f'browserstack_executor:{json.dumps(action)}')
我一直invalid action
在尝试我尝试过的所有 3 种方法,因此必须有其他东西可以摆脱浏览器堆栈机器上的文件。
解决方案
我相信“browserstack_executor”是特定于 BrowserStack 的自定义执行程序,它可以执行的操作集有限。
支持的操作可在其文档中找到: https ://www.browserstack.com/docs/automate/selenium/test-file-upload https://www.browserstack.com/docs/automate/selenium/test-file-下载
因此,无法执行诸如 removeFile 或 unlinkFile 或 deleteFile 之类的操作,因为它们当前不受支持,并且在上面共享的链接中也未提及。
推荐阅读
- python - Ansible - 访问另一台主机的变量
- javascript - 如何修复警告“eslint-disable-next-line no-unused-expressions”?
- python-3.x - Selenium Python 迭代 ol 中的 li 元素
- javascript - 在 Javascript 中比较 2 Array 是什么意思?
- javascript - 为什么更新许多没有猫鼬
- java - 避免连接到主动/被动 ActiveMQ 时出现错误消息
- tensorflow - 为什么使用的 gpu 设备与日志信息不一致?
- reactjs - 用另一个数组中的元素更新数组
- android - 如何处理android日历中实例的日期、日期和时间戳?
- javascript - 将字符串数组分组到包含嵌套数组的对象中