【问题标题】:Switching between browser tabs - Appium在浏览器选项卡之间切换 - Appium
【发布时间】:2018-11-06 14:06:27
【问题描述】:
    # get current window handle
    window_before = self.driver.window_handles[0]

    # click on a button which opens a new tab
    self.driver.find_element(*EditLocators.preview_button).click()

    # wait for new tab to open
    self.wait_for_new_tab()

    # get the new tab's window handle
    window_after = self.driver.window_handles[1]

    # switch to new tab
    self.driver.switch_to.window(window_after)

    "do some actions in new tab"

    # close that new tab
    self.driver.close()

    # switch back to original tab
    self.driver.switch_to.window(window_before)

以上是我在 chrome 浏览器中对一个网站进行的 appium 测试的代码 sn-p,它正在物理设备(android)上运行。网页上有一个按钮,可以打开一个新标签。我必须在这两个选项卡之间切换,但出现此错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: 'name' must be a string
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.38.552522 
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.15.0-38-generic x86_64)

在这一行:

self.driver.switch_to.window(window_after)

我的appium服务器版本是1.8.1,appium python客户端版本是0.28。

当我打印“window_before”和“window_after”变量时,结果分别是 CDwindow-0 和 CDWindow-1

【问题讨论】:

    标签: python-3.x appium


    【解决方案1】:

    将 appium 服务器从 1.8.1 更新到 1.9.1 解决了问题

    【讨论】:

      猜你喜欢
      • 2017-03-21
      • 2014-01-06
      • 2014-10-20
      • 1970-01-01
      • 2021-02-19
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多