python - 如何使用 selenium Python 单击框架和 iFrame 中的项目
问题描述
我要做的是单击此复选框。但是,它在 iframe 和框架中。我不确定如何选择这个。我继续得到一个未找到的元素。我已经通过 ID、名称和 Xpath 进行了尝试。
HTML:
<iframe id="myframe" style="background-color: rgb(255, 255, 255); width: 100%; position: absolute; height: 829px; display: block;" src="/f5-w-687474703a2f2f6e617973636c75737465722e6e63722e636f6d3a3830$$/MSL/jsp/MSLReDirect.jsp?ep=GIMV">
<frameset rows="100%,*" framespacing="false" frameborder="0" scrolling="No" noresize="" marginwidth="0" marginheight="0" border="false">
<frame src="f5-h-$$/GIM/GIM?TARGET_PROCESSOR=com.ncr.gim.processor.OPFProcessor&REQ=GIMA&pageAccess=&LAZ=Wed Mar 31 15:04:02 EDT 2021" name="GIMA" frameborder="0" border="0" scrolling="auto">
<input type="checkbox" id="StatusCheck" name="StatusCheck">
</frame>
</frameset>
</iframe>
我的脚本
driver.implicitly_wait(10)
driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))
driver.switch_to.frame(driver.find_element_by_tag_name("frame"))
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="Advanced3"]/input[1]'))).sendkeys("test")
driver.switch_to.default_content()
解决方案
推荐阅读
- javascript - 如果 GeoJson 属性为空,如何使 Leaflet 的 onEachFeature 下的此方法产生不同的结果?
- android - Room Repository:按 ID 选择一行
- python - 如何使用带有 Dask 的正则表达式删除行?
- jwt - 在将 JWKS 与 Auth0 一起使用时,如果我使用的是 localhost,那么受众和发行者是什么?
- node.js - Parse Server 平台 Live Query 是否适合私人聊天?
- react-native - 如何使本机部分列表反应到折叠部分并跨部分拖放项目?
- python - 在 python 中解释 split('e') 中的字符串“轮陡字符串”
- kubernetes - 我可以在没有任何 RBAC 的情况下运行 minikube 吗?
- typescript - 如何在 TypeScript 中为静态属性和方法调用注释类别名?
- swift3 - 如何在 iOS 应用中播放 Vimeo 私人和公共视频(swift 3)