你好,我找不到让selenium点击。。。发布网页上的按钮,如:https://www.instagram.com/p/B9LHHvygBnz/
其中,帖子角上三个点的源代码如下:
<div class="MEAGs">
<button class="wpO6b " type="button">
<div class=" Igw0E rBNOH YBx95 _4EzTm " style="height: 24px; width: 24px;">
<svg aria-label="More options" class="_8-yf5 " fill="#262626" height="16" viewBox="0 0 48 48" width="16">
<circle clip-rule="evenodd" cx="8" cy="24" fill-rule="evenodd" r="4.5"></circle>
<circle clip-rule="evenodd" cx="24" cy="24" fill-rule="evenodd" r="4.5"></circle>
<circle clip-rule="evenodd" cx="40" cy="24" fill-rule="evenodd" r="4.5"></circle>
</svg>
</div>
</button>
我已经尝试了很多我认为可行的方法,但selenium并没有指出这一点,例如,我尝试了:
self.driver.find_element_by_xpath("//div[@class='MEAGs']")
及
posts = self.driver.find_elements_by_xpath("//div[@class='wpO6b ']")
还有很多其他的方法(我已经在这一行代码上工作了2天!)
您应该始终尝试单击可以接收单击的元素,在本例中是在
button
xpath:
//div[@class='MEAGs']/button
相关问题 更多 >
编程相关推荐