0
votes

I am very new to Silenium.

I try to build a test that will validate whether web element (small icon) is shown on the page.

So, on the top of my class I defined Web element, by xpath.
Xpath I copied from Inspect after applying right click on the element and clicking Inspect.

@FindBy(xpath = "//*[@id="referrals"]/tbody/tr[2]/td[2]/div/img[2]") private WebElement ChainAndTwoArrowsIcon;

Then in the same class I have a method that evaluates whether my icon is appears:

public boolean IconChainWithArrowIsFound() throws InterruptedException {
    return ChainAndTwoArrowsIcon.isDisplayed()
            && ChainAndTwoArrowsIcon.getAttribute("title").toString().contains("Associated, and was successfully sent.");   
}

This is the last bit of my code and all xpath references I used in the same code worked fine same about all of the code.

However, I am getting an error at the end of the run for this bit I described:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="referrals"]/tbody/tr[2]/td[2]/div/img[2]"}

Please, see the image attached

xPath image

Can I have an advice what could potentially be wrong? Thank you in advance.

1

1 Answers

0
votes

Please check if the page has frames/iframes and the element you are trying to find is inside a frame/iframe. If so, you will need to first switch to the said frame using driver.switchTo().frame('frameName') and then you should be able to locate your element.