Reputation: 51
I have a tabel with more rows and I need to look for specific "selecttext1". -class myclass is not enough, because it is used for every row -href="#/test/id_var1 it's changing every time and I don't know its value
<td class="myclass">
<a class="ng-binding" href="#/test/id_var1">selectthistext1</a>
</td>
<td class="myclass">
<a class="ng-binding" href="#/test/id_var2">selectthistext2</a>
</td>
Upvotes: 4
Views: 28183
Reputation: 147
You can locate the button with any of the following CSS selector approach
By Class
Syntax: tag.Classname
By.cssSelector("button.btn addWidgButt bt-block");
By Attribute and Value
Syntax: [attribute='value']
By.cssSelector("button[context='UNIQUE_THING']")
Upvotes: -1
Reputation: 350
Use the Following CSS Selectors
css=.ng-binding[href*='id_var1'] -- CSS Selector for Link Text selectthistext1
css=.ng-binding[href*='id_var2'] -- CSS Selector for Link Text selectthistext2
Please Let me know is the above CCS Selectors are working or Not.
Upvotes: -1
Reputation: 1105
You can use linktext or xpath as follows:
driver.findElement(By.xpath("//a[text()='selectthistext1']"));
//OR
driver.findElement(By.linkText("selectthistext1"));
You may also look at the answer: Need to find element in selenium by css and Writing cssselector expression for webDriver using attribute matching
Upvotes: 6