I am new to selendroid and writing test case for my app.
I have a login page which is displayed only if user is not logged in. I am able to execute test first time and login successfully. I have set noClearData flag true so that I can have data for further process.
Since I am already logged in so home page is open up when I run test second time but code tries to get element by id "email" and throws exception
org.openqa.selenium.NoSuchElementException: Element was not found.
io.selendroid.exceptions.NoSuchElementException: Element was not found.
at io.selendroid.server.handler.FindElement.handle(FindElement.java:58)
at io.selendroid.server.AndroidServlet.handleRequest(AndroidServlet.java:301)
at io.selendroid.server.BaseServlet.handleHttpRequest(BaseServlet.java:67)
at io.selendroid.server.http.ServerHandler.channelRead(ServerHandler.java:50)
.....
I am checking if element is displayed with below code
WebElement inputFieldEmail = driver.findElement(By.id("email"));
inputFieldEmail .isDisplayed()
but driver.findElement throws exception and test case gets failed. I want to check that if login page is open then only above code is executed.
Please help.
Thanks