Following is my code :
case BrowserType.PhantomJS: var service = PhantomJSDriverService.CreateDefaultService(Path.Combine(_rootPath, @"Packages\")); var cookieFilePath=Path.Combine(_rootPath, @"Packages\cookie.txt"); if (!File.Exists(cookieFilePath)) File.Create(cookieFilePath); var phantomjsoptions = new PhantomJSOptions(); driver = new PhantomJSDriver(service,phantomjsoptions); var cookieJar = driver.Manage().Cookies; driver.Navigate().GoToUrl(SeleniumConfiguration.Current.BaseURL); cookieJar.AddCookie(new Cookie("x", "12345")); return driver;
Basically the issue is that i am not able to login into my test application because i get an error saying -
"Your browser is set to block cookies"
I've tried everything but i just can't seem to get the solution for this.
what should i do?
Please help me out here.
Let me know if there is some detail missing.
Using Selenium WebDriver API, we can query and interact with browser cookies with the help of following WebDriver's built-in methods. Get Cookies: This statement is used to return the list of all Cookies stored in web browser. manage(). getCookies();
When the code is executed, webdriver will store the cookie information using FileWriter Class to write streams of characters and BufferedWriter to write the text into a file named “Cookiefile. data“. The file stores cookie information – “Name, Value, Domain, Path”.
RFC 2109 explicitly forbids cookie accepting from URLs with IP address
You are almost certainly accessing your test server via an IP based address.
You can try set up some kind of DNS/host file to allow you to use a fake domain name.
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