I am writing automation code to scrape datas from google by uploading a excel file and result with excel file. I know it will throw No such element exception, so i used try and catch block. even though i tried it, it throws the same exception. I cant find it anywhere.
the catch i entered-
catch (NoSuchElementException e) {
noReviewList.add(query);
System.out.println("No review found for query: ");
}
The error i got-
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"(//span[contains(text(),'Google reviews')])[1]"}
(Session info: chrome=127.0.6533.100)
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Build info: version: '4.22.0', revision: 'c5f3146703*'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.12'
I know some inputs cannot find the datas, even though I tried try catch, its not working
New contributor
Vishal R R is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.