0

Native code for what i want to make automation.This is the a href tag

<a href="http://www.itpathsolutions.cu.ma/juniorApp/admin/user">
                <i class="fa fa-user"></i> <span>User Management</span>
                <small class="label pull-right bg-red">10</small>
              </a> here
kunal soni
  • 585
  • 1
  • 7
  • 19
  • Possible duplicate of [How to get value from

    tag in Selenium WebDriver, Java](http://stackoverflow.com/questions/11902953/how-to-get-value-from-h3-tag-in-selenium-webdriver-java)

    – Maouven Feb 16 '16 at 11:29
  • Need to add more html where contains – Mesut GUNES Feb 16 '16 at 11:47

2 Answers2

0

XPATH

//a[contains(@href, 'itpathsolutions')]

OR

//span[text()='User Management']/../a
Nguyen Vu Hoang
  • 1,570
  • 14
  • 19
  • Its not working.I have already tried it, driver.findElement(By.xpath("//a[contains(@href,'http://www.itpathsolutions.cu.ma/juniorApp/admin/user'")).click(); – kunal soni Feb 16 '16 at 13:00
  • Both is not working? Edited the 2nd one. It should work. – Nguyen Vu Hoang Feb 16 '16 at 13:01
  • Wrong syntax. Should be driver.findElement(By.xpath("//a[contains(@href,'itpathsolutions.cu.ma/juniorApp/admin/user')]")).click() – Nguyen Vu Hoang Feb 16 '16 at 13:01
  • I have tried the first one. But it didnt work. I dont understand second one.How to use driver.findElement(By.xpath("//span[text()='User Management']/../a")).click(); like this? – kunal soni Feb 16 '16 at 13:22
  • 1st one, you used wrong syntax, please take a look at my 3rd comment; 2nd one: yes – Nguyen Vu Hoang Feb 16 '16 at 13:26
0

if you want to click on give link then try following code.

 WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            wait.Until(ExpectedConditions.ElementExists(By.LinkText("User Management 10"))).Click();

if any issue then let me know.

Muhammad USman
  • 208
  • 1
  • 6