简体   繁体   中英

Having trouble clicking a link with selenium webdriver/java

I'm trying to click the link below:

 <td id="mainleftlinkzoneover" class="mainleftlinks" width="151" title="Student Medicaid  Eligibility">

Here's the code. It works with other links like this but not this one.

        WebElement myElement = (new WebDriverWait(driver, 30))
              .until(ExpectedConditions.elementToBeClickable(By.cssSelector("td[title='Student Medicaid  Eligibility']")));
        myElement.click();

Anyone have any ideas what I'm doing wrong?

you can do it by using the below code:

By.id("mainleftlinkzoneover") //here only id is used

or

By.cssSelector("#mainleftlinkzoneover[title='Student Medicaid  Eligibility']") // this is another way to locate element

use the any one instead of your By.cssSelector.

Make sure there are no frame.

Is the link available for others to check? I mean can I test it if I want? you can give the url if possible.

here are my 2 cents:

I am thinking because of the spaces in your title, you might not be able to click on it. I would try using contains something like By.xpath("//td[contains(@title,'Eligibility')]") you can put either student or medicaid if they are unique. See if that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM