Can Selenium WebDriver be used for automating ReactJs application ? I started using Selenium WebDriver, and stuff is getting done but in really slow fashion because I am encountering a lot of issues in finding elements in the ReactJS web-app. Not sure of the clear reason that why is WebDriver not able to find elements in ReactJS web-app unlike other applications that run in a browser.
-
1hey what are the issues to find the element?A user– A user2017-05-12 11:27:20 +00:00Commented May 12, 2017 at 11:27
-
1@Pri This exception occurs sometimes and sometimes does not- selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button id="actions" role="button" aria-haspopup="true" aria-expanded="false" type="button" class="dropdown-toggle btn btn-sm btn-primary">...</button> is not clickable at point (1269, 176). Other element would receive the click: <button id="actions" role="button" aria-haspopup="true" aria-expanded="false" type="button" class="dropdown-toggle btn btn-sm btn-primary">...</button>AlwaysNoob– AlwaysNoob2017-05-16 11:09:44 +00:00Commented May 16, 2017 at 11:09
2 Answers
In fact, Selenium will work for all websites, it doesn't matter the sites are developed by which technology (because after all, after sites some to browsers, they're just HTML, CSS and also JS)
Therefore, as far as I know, perhaps because of the way react-sites' elements have inline css (and may not have Class or ID), so it makes it more difficult for the Selenium web driver to find DOM elements, that's it!
Comments
From your exception, it appears that Selenium has located the element but it is not clickable. One of the reasons could be changing states of the element which happens in case of ReactJS e.g. username and password fields on Gmail login.
I have also stumbled on a similar problem but I have narrowed down the cause to randomly changing ID of the element. You might be able to solve it by requesting developer to use ID against each element so that it can make locating elements easier.
Another option could be to use partial link to locate the element