2013-04-25 75 views
8

我怎么可以点击硒的webdriver C#查找HREF路径元素

<a href="Vacancies.aspx?param=apply:16 " title="Please click to apply ">Apply</a>

我有几个应用页面上的链接。我应该点击apply:16(不适用:10,11,n)。

我有一个脚本(的Watir,红宝石):

browser.link(:href, "Vacancies.aspx?param=apply:16").click

其应如何对硒的webdriver C#?

我试过
driver.FindElement(By.LinkText("Apply")).Click(); 但正如你所理解的,这不是工作。

谢谢

回答

19

试试看下面的定位器。

By.CssSelector("[href*='Vacancies.aspx?param=apply:16']") 
+0

谢谢!作品! – 2013-04-25 11:20:00

+0

工程就像一个魅力 – ilans 2015-09-27 11:17:49

0

就像整理Santoshsarma的工作一样!

def <yourbutton> = driver.findElement(By.cssSelector("[href*='Vacancies.aspx?param=apply:16']"))