There is a .delete_all_visible_cookies
method in Selenium. I was surprised to discover that .delete_all_cookies
in Webdriver is a part of private API thus is not accessible through @driver instance.
It is a problem for IE since it does not start a clean browser on a new test run as FF.
We can delete cookies on all domains with Selenium. The method deleteAllCookies is used to delete all cookies from the present domain.
ContextClick Method. Right-clicks the mouse at the last known mouse coordinates.
Selenium WebDriver provides multiple commands for handling the cookies in a website. These Selenium cookies APIs provide you the required mechanism for interacting and querying the cookies. In Selenium Java, these methods are a part of the org. openqa.
From what I know you have to options:
When creating the IE instance use capabilities argument:
DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); WebDriver driver = new InternetExplorerDriver(caps);
Once initialized, you can use:
driver.manage().deleteAllCookies()
Unfortunately, I was not able to solve this issue by means of Webdriver. Finally, what I do is simply delete the cookies from the command line before running the tests. The line is
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With