Possible that some elements just can't be located?

I know the title is somewhat clickbait ish but I am at my wit’s end with trying to locate a radio button to click on a page.
To give some background, this is a internal app/site using a private location/containerized minion.

This site uses 99% dynamic elements so i’m forced to use full xpath about 99% of the time throughout the script. So I’m about half way into the script, trying to locate a radio button to click and now full xpath is not working for me.
I’ve tried css, xpath, and full xpath and nothing seems to work.
Here is the function…most recently i tried full xpath while adding some additional details to input:

.then(function() {
return $browser.findElement(By.xpath(’/html/body/div[2]/div[2]/div[2]/div[5]/p[1]/div/div/div[4]/input[@type=“radio” and @value=“N”]’))
.then(function(button) {
button.click();
});
})

Link to the script:

https://synthetics.newrelic.com/accounts/2010833/monitors/858467b7-4f13-4540-8609-fd929c11d24b/script

1 Like

Hi @tris.maddox, firstly it may be better to use the waitForAndFindElement() function here in case there is any delay in the element rendering on the page. There is also an example here of using that method to click a radio button.

Have you tried using the name instead of value to locate it, or simply the $driver.By.name() instead of xpath?

Another option you could try is using the $browser.findElements() function with By.xpath(’//input[@type=“radio”]’), this will return an array of all Radio buttons on the page. If this is the only one you can use elements[0].click(), or if there are multiple you can print the array to the console to see what position the correct one is in.

Hope that helps :slight_smile:

4 Likes

Hi @rdouglas

thanks for the response. I figured out what the issue was half of the site is inside of an iframe but you can’t tell just by looking at the site. so i had to switch to the frame first and then continue locating elements.

thanks,

5 Likes

Thanks for letting us know what the solution was for you @tris.maddox