How to capture JS error with selenium Webdriver

Source: Internet
Author: User
Tags selenium grid

# # # Problem

Capture the page JS error

# # # Solution

Parsing from Selenium Webdriver log

#-*-Coding:utf8-*-ImportUnitTest fromSeleniumImportWebdriver fromSelenium.webdriver.common.desired_capabilitiesImportdesiredcapabilitiesclassCapturejserror (unittest. TestCase): @classmethoddefsetUp (self): Self.driver= Webdriver. Remote ('Http://yourseleniumgrid:4444/wd/hub', Desired_capabilities=Desiredcapabilities.firefox)deftest_search_in_python_org (self): driver=self.driver Driver.get ("http://foopagewitherr:80") Logs= Driver.get_log ('Browser')         forLoginchlogs:iflog[' Level'] =='SEVERE':                PrintLog#output is {u ' timestamp ': 1474618002360, u ' message ': U ' TypeError: $ (...). Ready_ is isn't a function ', U ' level ': U ' SEVERE '}@classmethoddefTearDown (self): Self.driver.close ()if __name__=="__main__": Unittest.main ()

Note:

The webdriver here is provided by Selenium grid, and local webdriver should be available as well.

# # Quotes

Https://www.3pillarglobal.com/insights/how-to-capture-javascript-errors-from-your-web-application

How to capture JS error with selenium Webdriver

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.