为什么我不能 select 这个? - 硒
Why can't I select this? - Selenium
以下内容已嵌入 到网页中。它不是实际站点的一部分:
我一直在尝试做的是 select 'previous meetings' 选项卡,在 Python.
中使用 Selenium
这些是两个按钮(即将召开的会议和之前的会议)的元素:
<div role="tab" aria-disabled="false" aria-selected="true" class="ant-tabs-tab-active ant-tabs-tab" tabindex="0" aria-label="Upcoming Meetings">Upcoming Meetings</div>
::before
Upcoming Meetings
</div>
<div role="tab" aria-disabled="false" aria-selected="false" class=" ant-tabs-tab" aria-label="Previous Meetings">Previous Meetings</div>
::before
Previous Meetings
</div>
我试过 driver.find_element_by_xpath('//*[@class=" ant-tabs-tab"]').click()
但没有检测到该元素。
当我查看网页的实际源代码时,这些缩放元素没有出现,所以我认为这就是为什么 Selenium 也无法识别它的原因。
它没有 ID 或其他任何东西,所以我无法尝试。有什么我可以做的吗? (例如,只需点击屏幕上的某个位置)
还是我做错了什么?
好像是iframe,开头是
<iframe src="about:blank" name="tool_content" id="tool_content" class="tool_launch" allowfullscreen="allowfullscreen" webkitallowfullscreen="true" mozallowfullscreen="true" tabindex="0" title="Tool Content" style="height:100%;width:100%;" allow="geolocation *; microphone *; camera *; midi *; encrypted-media *; autoplay *" data-lti-launch="true"></iframe>
如果有帮助的话。
更新:
我尝试使用 Firefox 的扩展,它为您提供了元素的精确 xpath:
driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div[1]/div[2]').click()
这仍然不起作用 - 为什么?
由于有 iframe 只需切换到它
driver.switch_to.frame("tool_content")
尝试使用
driver.switch_to.frame(driver.find_element_by_class_name("tool_launch"))
以下内容已嵌入 到网页中。它不是实际站点的一部分:
我一直在尝试做的是 select 'previous meetings' 选项卡,在 Python.
中使用 Selenium这些是两个按钮(即将召开的会议和之前的会议)的元素:
<div role="tab" aria-disabled="false" aria-selected="true" class="ant-tabs-tab-active ant-tabs-tab" tabindex="0" aria-label="Upcoming Meetings">Upcoming Meetings</div>
::before
Upcoming Meetings
</div>
<div role="tab" aria-disabled="false" aria-selected="false" class=" ant-tabs-tab" aria-label="Previous Meetings">Previous Meetings</div>
::before
Previous Meetings
</div>
我试过 driver.find_element_by_xpath('//*[@class=" ant-tabs-tab"]').click()
但没有检测到该元素。
当我查看网页的实际源代码时,这些缩放元素没有出现,所以我认为这就是为什么 Selenium 也无法识别它的原因。
它没有 ID 或其他任何东西,所以我无法尝试。有什么我可以做的吗? (例如,只需点击屏幕上的某个位置)
还是我做错了什么?
好像是iframe,开头是
<iframe src="about:blank" name="tool_content" id="tool_content" class="tool_launch" allowfullscreen="allowfullscreen" webkitallowfullscreen="true" mozallowfullscreen="true" tabindex="0" title="Tool Content" style="height:100%;width:100%;" allow="geolocation *; microphone *; camera *; midi *; encrypted-media *; autoplay *" data-lti-launch="true"></iframe>
如果有帮助的话。
更新:
我尝试使用 Firefox 的扩展,它为您提供了元素的精确 xpath:
driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div[1]/div[2]').click()
这仍然不起作用 - 为什么?
由于有 iframe 只需切换到它
driver.switch_to.frame("tool_content")
尝试使用
driver.switch_to.frame(driver.find_element_by_class_name("tool_launch"))