Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.6k views
by Contributing Tester (53 points)

Hi. I have written program I used Selenium and Firefox, but when I switch to PhantomJS, just one line

self.driver = webdriver.Firefox() => self.driver = webdriver.PhantomJS()

I do not get all cookies(like with Firefox), so do I need to set additional parameters or something else? 

by The go-to Tester (181 points)
can you post your code to get cookies?
by Contributing Tester (53 points)
self.driver = webdriver.PhantomJS()
self.driver.get(self.URL_LOGIN)
time.sleep(3)

# insert user name
username = self.driver.find_element_by_id('username')
username.clear()
username.send_keys('username')

# insert password and submit
password = self.driver.find_element_by_id('password')
password.clear()
password.send_keys('password')

password.submit()
time.sleep(5)

self.driver.get(self.URL_REPORT)

after I can get all cookies
cookies = self.driver.get_cookies()
        for cookie in cookies:
            print(cookie['name'], cookie['value'])

but when I use Firefox I get more cookies.

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer
Number of cookies will definitely change from browser to browser, depending on how your application developer has developed the application. Your code looks good and its picking up all required cookies.

If you are not getting the expected cookies set, can you post difference of cookies here?
by The go-to Tester (181 points)
You can even try taking screenshots and attach it by editing your question.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...