by.xpath问题自动单击硒

发布于 2025-01-21 04:21:30 字数 1021 浏览 0 评论 0 原文

我想自动单击喜欢的蓝色徽标(内部拇指的徽标),以打开那些留下喜欢的人的列表。我指的是这个小蓝色徽标:

”在此处输入图像说明“

在我只想关注这个小请求的问题中,这是一个小单击。我想我做对了,但是肯定有问题。我使用 by.xpath 。,更精确: //*[@ID =“ JSC_C_Z”]/span [1]/span/span/span/span/div

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="jsc_c_z"]/span[1]/span/span/div'))).click()

nota:i' VE注意到,此页面上的ID和范围看起来令人怀疑,因此也许每次它们都不一定是一样的。因此,也许我不认为ID =“ JSC_C_Z”将是可靠的。您可能需要诉诸于目标元素div上的属性的aria-labeld。

相反,这是我想打开的链接

重要的是:您必须输入Facebook登录,但是谁不想这样做会发布屏幕截图

我希望有人可以帮助我。谢谢

I would like to automatically click on the blue logo of the likes (the one with the thumb inside), in order to open the list of those who have left the likes. I am referring to this little blue logo:

enter image description here

In the question I want to focus only on this small request, on this small click. I think I am doing it right, but surely there is something wrong. I used By.XPATH., More precisely: //*[@id="jsc_c_z"]/span[1]/span/span/div

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="jsc_c_z"]/span[1]/span/span/div'))).click()

NOTA :I've noticed that the IDs and ranges on this page look suspiciously obfuscated and so maybe they won't necessarily be the same every time. So maybe I don't think id = "jsc_c_z" that will be reliable. You may need to resort to using aria-labeld of the attribute on the target element div.

This instead is the link I would like to open https://www.facebook.com/FranzKafkaAuthor/posts/3985338151528881.

IMPORTANT: You have to enter with the Facebook login, but who does not want to do so will post a screenshot
enter image description here

I hope someone can help me. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧话新听 2025-01-28 04:21:30

嘿,您可以尝试这样的XPATH,

//*[@id="jsc_c_z"]/span[3]/div/img

因为图像标签具有链接,而不是DIV标签
如果它不起作用,请尝试在定位DIV时添加Arial标签。

Hey you can try the Xpath like this,

//*[@id="jsc_c_z"]/span[3]/div/img

as the image tag has the link and not the div tag
If it does not work, try adding the arial label while locating the div.

街角卖回忆 2025-01-28 04:21:30

此页中的ID和跨度看起来令人怀疑,因此每次都不一定是相同的。我认为 id =“ JSC_C_Z” 是可靠的。您可能需要诉诸于目标 div 元素上的 aria-label 属性。我无法测试这一点,但是xpath将是类似的东西。

//div[starts-with(@aria-label,'Mi piace:')]

当然,如果您要为具有不同语言的用户运行此文本,则需要更改该文本。

the ids and spans in this page look suspiciously obfuscated, and thus won't necessarily be the same every time. I don't think the id="jsc_c_z" will be reliable. you may need to resort to using the aria-label attribute on the target div element. I can't test this, but the xpath would be something along the lines of;

//div[starts-with(@aria-label,'Mi piace:')]

and of course, you'd need to change that text if you are running this for users with different languages.

燃情 2025-01-28 04:21:30

我自己解决了。解决方案是:

 WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='j1lvzwm4']"))).click()

I solved it by myself. The solution was:

 WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='j1lvzwm4']"))).click()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文