Skip to content Skip to sidebar Skip to footer

Selenium Phantomjs Browsers Hangs On Startup. How Do I Debug It?

I'm trying to help run my selenium (Python bindings version 2) tests on someone else setup. It works with the Firefox esr(on both machines), it works with the latest phantomjs on

Solution 1:

More details could help. Do you get an error message? How is your code?

In any case, some ideas that may help to figure out what is happening are:

Set the window size to something appropriate for your tests.

driver.set_window_size(900, 800)

Save screenshots.

driver.save_screenshot('screen.png')

Check if the page source matches your expectations.

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

You may try to see if upgrading Selenium helps.

pip install selenium --upgrade

You may test other versions of PhantomJS, by downloading and specifying the path. Version 1.9.8 helped me with bypassing 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!


Post a Comment for "Selenium Phantomjs Browsers Hangs On Startup. How Do I Debug It?"