简体   繁体   English

Selenium,如何找到这个元素

[英]Selenium, how to find this element

在此处输入图像描述

I need to find the webelements like id="rcmrowgeneral" .我需要找到像id="rcmrowgeneral"这样的网络元素。

A standard driver.find_element_by_id() is not working.标准的driver.find_element_by_id()不工作。 It's like they are inside another HTML page.就像他们在另一个 HTML 页面中一样。 How can I find them with selenium to interact with them?我如何通过 selenium 找到他们并与他们互动?

You can do this by following the selenium syntax which states if you want to find a specific tag inside an iframe you have to switch to that iframe first and then you can use selenium query to find it.您可以通过遵循 selenium 语法来执行此操作,该语法声明如果您想在 iframe 中查找特定标签,您必须先切换到该 iframe,然后您可以使用 selenium 查询来查找它。 Since you've not posted any code over here i assume you've background knowledge of handling automation processes.由于您尚未在此处发布任何代码,我假设您具有处理自动化流程的背景知识。 You can do this task by following this naming convention:您可以按照以下命名约定完成此任务:

driver.switchTo().frame("id or name of the element")
driver.find_element_by_id("your id here")

Your element is inside of an iframe. First you need to switch to the iframe and then it is a good practice to wait for the element to be visible/clickable before interacting with it.您的元素位于 iframe 中。首先,您需要切换到 iframe,然后最好等待元素可见/可点击,然后再与其交互。

driver.switch_to().frame(driver.find_element_by_id("TiscaliWebmailFrame"))
WebDriverWait(driver, 20).until(expected_conditions.presence_of_element_located((By.ID, "rcmrowgeneral"))).click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM