browserstack_executor 操作列表在哪里?

问题描述 投票:0回答:3

我发现了以下内容的用途,但没有使用 browserstack_executor 进行其他可能操作的文档:

  1. 文件存在
  2. 获取文件内容
  3. 获取文件属性
  4. 设置会话状态

我正在寻找

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)}')

在我尝试过的所有 3 个方法中,我一直得到

invalid action
,所以必须有其他东西可以在 browserstack 上删除机器上的文件。

selenium-webdriver browserstack
3个回答
0
投票

我相信“browserstack_executor”是特定于 BrowserStack 的自定义执行器,并且它可以执行的操作集有限。

支持的操作可在其文档中找到: https://www.browserstack.com/docs/automate/selenium/test-file-upload https://www.browserstack.com/docs/automate/selenium/test-file-download

因此,无法执行诸如removeFile或unlinkFile或deleteFile之类的操作,因为当前不支持它们,并且上面共享的链接中也未提及它们。


0
投票

根据公司支持人员的说法,没有列表,也不支持取消链接。为了解决这个问题,我修改了 FileExists ExpectedCondition,用于在从测试系统中提取文件名后自动递增文件名,并使用“下一个可用”名称,以便我的测试可以在本地或在浏览器堆栈。


0
投票

可以在此处找到文档: https://www.browserstack.com/docs/automate/selenium/js-executors

此页面的优点是在详细信息栏中列出了产品(Automate 与 App Automate)。

也不要被 URL(自动化/selenium)所迷惑,只要您使用的框架支持execute*(或类似)方法,所有

driver.execute_script
命令都应该有效。例如 WebdriverIO 使用:
await driver.execute()
.

© www.soinside.com 2019 - 2024. All rights reserved.