I am writing test cases using Selenium and PhantomJsDriver in Java
Selenium - 3.0.1
PhantomJs - 2.1.1
Expected Scenario : Open a pop-up page and find the No of elements inside the pop up page (Actually the items getting displayed inside the pop up).
At any given point of time there can be only 3 elements inside the pop up. So i am doing an assert here.
Below is the Code for the same
With Class Name using
findElementsmethodList<WebElement> foundItems = By.className("className").findElements(driver); int count = foundItems.size();With
Xpathint count = driver.findElements(By.xpath("//div[@class='className']")).size();
In both the cases i am getting the count wrong, i always get the count as multiple of elements which are inside the pop up page.
But if i iterate over the list and use .isDisplayed() method and maintain a flag it is giving me the correct count.
I think it might be an issue of cache or localStorage issue which phantomJsDriver maintains.
How could i clear the Cache or LocalStorage using Selenium and Java.
Or is there any other way to get it done.
You should provide HTML of your page so we could help you.
As for the local storage, you can delete it using javascript, this should work fine: