Repo1
Repo2
Repo3
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内容请搜索靠谱客的其他文章。
发表评论 取消回复