概述
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 Selenium如何单击特定文本旁边的按钮?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复