2013-04-25 38 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']"))