简体   繁体   中英

How to get expected link from same named link on Web Page?

I am using Selenium with C# for doing automation of Web Page. I wanted to click on link named Edit .

I used following code to click on Edit,

driver.FindElementByPartialLinkText("Edit").Click(); 

Now, problem is my page has multiple links named Edit , I have attached following screen shot for more clarity.

I wanted to click link which is in table. I tried to copy XPath using Chrome Developer tool, but it is very specific, I may get more rows in table, so it will not be generic solution.

I got distinguished title (not text), can I used it with XPath?

您可以看到多个修改

You can get a list of the web elements and then filter based on the title text. Something like this should workd

List <WebElement> list= driver.findElements(By.linkText ( text ) );

and then iterate the list of element and look for the title u are looking for using

if (element.getAttribute("title").equals("Something")
     //Do something

and perform the action based on that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM