我是靠谱客的博主 儒雅丝袜,最近开发中收集的这篇文章主要介绍python输入文字点击按钮,Python Selenium如何单击特定文本旁边的按钮?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Repo1

Delete

Repo2

Delete

Repo3

Delete

In the above code I want to click the Delete button, the problem is that every time a Repo is added, the class name of the repo, the class name of the display text, and the class name of the delete button is all the same for all the repos except for the repo display name.

All I want to do is click the delete button next to a specific repo name.

I tried .//span[text() = "RepoName"] but this only detects the repo name and not the button next to it.

I am pretty new to selenium and I am confused on how to go about it.

解决方案

If you want the button div after a certain RepoX, find the span and get the following div with the Button class:

.xpath("//span[text()='Repo3']/following::div[@class='Button']")

If you did not know the class name but you know it is the next div:

.xpath("//span[text()='Repo3']/following::div[1]")

最后

以上就是儒雅丝袜为你收集整理的python输入文字点击按钮,Python Selenium如何单击特定文本旁边的按钮?的全部内容,希望文章能够帮你解决python输入文字点击按钮,Python Selenium如何单击特定文本旁边的按钮?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部