无法定位元素 python selenium - 需要单击此按钮
Unable to locate element python selenium - Need to click this button
所以,这个按钮没有 id/name,我试过 xpath、class 名称、CSS 选择器等
这里是 HTML 代码:
提前致谢。
你可以尝试一种丑陋的技巧:
- 获取所有 button/span 个元素
- 循环所有 button/span 元素,直到找到文本。
- 然后单击该元素...
类似于:
all_span_elements = driver.find_elements_by_tag_name("span")
for span_element in all_span_elements:
if "Begin Lesson" in span_element.text:
span_element.click()
一定要切换到包含这个按钮的iframe!然后我认为这个 CSS 路径应该有效:
div.submit-and-reset-wrapper button.continue
所以,这个按钮没有 id/name,我试过 xpath、class 名称、CSS 选择器等
这里是 HTML 代码:
提前致谢。
你可以尝试一种丑陋的技巧:
- 获取所有 button/span 个元素
- 循环所有 button/span 元素,直到找到文本。
- 然后单击该元素...
类似于:
all_span_elements = driver.find_elements_by_tag_name("span")
for span_element in all_span_elements:
if "Begin Lesson" in span_element.text:
span_element.click()
一定要切换到包含这个按钮的iframe!然后我认为这个 CSS 路径应该有效:
div.submit-and-reset-wrapper button.continue