Selenium Phantomjs browsers freeze at startup. How to debug it?

I am trying to help run selenium tests (Python bindings version 2) for someone else.

It works with Firefox esr (on both machines), it works with the latest phantomjs on my machine. He is hanging in his car.

The only obvious difference is that it works on Windows 10, and I work on Windows 7. I don’t think it’s a firewall or proxy server because I took care of it (by enabling everything for the firewall and starting it with --proxy-type=none ) ..

How to debug it?

+6
source share
1 answer

More details may help. Did you receive an error message? How is your code?

In any case, some ideas that may help figure out what is going on:

Set the window size for something suitable for your tests.

 driver.set_window_size(900, 800) 

Save screenshots.

 driver.save_screenshot('screen.png') 

Check if the page source meets your expectations.

 with open('temp.html', 'w') as f: f.write(driver.page_source) 

You can try to find out if updating Selenium helps.

 pip install selenium --upgrade 

You can test other versions of PhantomJS by downloading and specifying a path. Version 1.9.8 has helped me circumvent some security restrictions in the past.

 driver = webdriver.PhantomJS( executable_path='/path/to/the/downloaded/phantomjs19', # you can specify args, such as: service_args=[ '--ignore-ssl-errors=true', '--ssl-protocol=any', '--web-security=false', ], # and also other capabilities: desired_capabilities={ 'phantomjs.page.settings.resourceTimeout': '5000', 'phantomjs.page.settings.userAgent': ( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 " "(KHTML, like Gecko) Chrome/15.0.87" ), }, ) 

Please let me know if this helps!

0
source

All Articles