Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

$driver.By.linkText - Having problems with links with spaces



I have this in my script:

// Select System Configuration
$browser.findElement($driver.By.linkText("System Configuration")).click();

Unfortunately the script keeps timing out. However, if I replace the linkText with the name of a single word link “Rates” in this case, the script works just fine. “Rates” and “System Configuration” both appear on the same menu. The difference between them seems to be the one word link vs two word link.

Anyone have any suggestions on how to work around this?


Thanks for posting to the forum!

I believe the problem here is the space between your two words might be interpreted as &nbsp, which would interfere with the exact match the linkText is looking for. Try replacing that line in your script with this:

$browser.findElement($driver.By.partialLinkText("System Configuration")).click();

The partialLinkText will look is a bit less conservative when searching, and should be able to find a match.


HI, I also encountered the same issue using By.linkText with spaces, as suggested i replaced it with By.partialLinkText but still i get time out issue. Any help?


Hi @Shashidhar.Naik, would you mind providing a permalink to the monitor you are having issues with and I can take a closer look :slight_smile:


@rdouglas i’m new to this monitoring, Can you please guide me on how to get the permalink ?


Hi @Shashidhar.Naik you can find instructions here permalink but for monitors you can copy and paste the URL in the Briwser :slight_smile:


@rdouglas below is the permalink asked,[start]=1566815581.665&tw[end]=1566817381.665




I would recommend making sure the element you are trying to click is a <a> element for the By.linkText selector strategy to work.

Are you able to share the HTML of the element you are trying to target? You can also try the following xpath strategy so you are not limited to <a> elements:

//*[contains(text(),'Find Companies')]

Reviewing some of the failed checks for this monitor, I think the failure to find this element might be a red herring, as it seems from the screenshot and the request errors in the last pages visited in the script reflect a name resolution error in trying to fetch the page, that it seems you expect the element to be present on. I would recommend reviewing if this hostname you are trying to reach is publicly resolvable.


Can you please provide the complete line of code using xpath pls?


Hi @Shashidhar.Naik, the xpath code would simply be the following:

$browser.findElement($driver.By.xpath("//*[contains(text(),'Find Companies')]"));

Let me know if that helps :slight_smile: