Search code examples
seleniumwebdriverhref

Selenium WebDriver C# find element by href path


How I can click on

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

I have a few Apply links on page. I should click on apply:16 (not apply:10,11,n).

I have a script (watir, ruby ) :

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

How its should be for Selenium WebDriver C# ?

I tried
driver.FindElement(By.LinkText("Apply")).Click(); But as you understood, this isnt work.

Thanks


Solution

  • Give a try with below locator.

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