【发布时间】:2015-11-30 17:14:04
【问题描述】:
在 Selenium IDE 中,它告诉我使用命令
selectWindow
目标是:
name={"id":"a52b0dc5-b1f5-2020-01db-139f01c0204a","containerVersion":"7-GA","webContextPath":"/345","preferenceLocation":"https:/url/345/prefs","relayUrl":"https:/url/o345/is/eas/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"345":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}
如何在 python 中使用driver.switch_to_window 进行转换?
我试过了:
driver.switch_to_window(driver.find_element_by_name("{"id":"a52b0dc5-b1f5-2020-01db-139f01c0204a","containerVersion":"7-GA","webContextPath":"/345","preferenceLocation":"https:/url/345/prefs","relayUrl":"https:/url/o345/is/eas/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"345":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}"))
建议?
【问题讨论】:
-
似乎IDE和WebDriver有不同的方式来识别对象...如果您想确定如何选择窗口:在所需窗口上单击右键,然后单击“探索元素的代码" 或类似的东西(取决于浏览器)来获取 html 源代码。复制它并使用这部分代码更新您的问题,然后我可以告诉您在 Python 脚本中使用的正确选择器
-
在窗口之间切换的非常简单的方法(理想情况下是 2 个)gist.github.com/ab9-er/08c3ce7d2d5cdfa94bc7。告诉我这是否适合你。
-
它对你有用吗?
-
请采纳答案。
标签: python selenium iframe selenium-webdriver