Selenium WebDriver C# find element by href path

白昼怎懂夜的黑 提交于 2020-01-02 01:59:30

问题


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


回答1:


Give a try with below locator.

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



回答2:


Just as a tidy up to Santoshsarma's work!

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


来源:https://stackoverflow.com/questions/16208925/selenium-webdriver-c-sharp-find-element-by-href-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!