Created
January 30, 2017 21:57
-
-
Save johndavidsimmons/eb3939e9d8c5a24d251085d0217a2a41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def visitPage(url, relativeUrl): | |
| global driver | |
| global HTML_string | |
| # Visit the page | |
| driver.get(url+relativeUrl) | |
| # Turn on staging and debug (Optional) | |
| # driver.execute_script(stagingScript) | |
| # driver.execute_script(debugScript) | |
| # Give the page time to load | |
| sleep(1) | |
| # log events and pagename | |
| # format with pipe for easy parsing | |
| # Without try/except this will fail if _satellite is undefined | |
| try: | |
| driver.execute_script('''console.log('|' + _satellite.getVar('Global - Pagename') + '|' + s.events + '|');''') | |
| # parse the entirety of the JS log to get my console.logs | |
| # Turn it into a list for easier var extraction | |
| log = str([entry[u'message'] for entry in driver.get_log('browser') if entry[u'level'] == 'INFO']).split('|') | |
| pageName, events = str(log[1]), str(log[2]) | |
| driver.save_screenshot(os.getcwd()+'/images/{}.png'.format(pageName)) | |
| HTML_string += '''<tr> | |
| <td><a href="{}.png" target="_blank">{}</a></td> | |
| <td>{}</td>'''.format(os.getcwd()+ '/images/'+pageName, pageName, events) | |
| if "event10" in events: | |
| HTML_string += "<td class='green'>Good</td>" | |
| else: | |
| HTML_string += "<td class='red'>Bad</td>" | |
| HTML_string += "</tr>" | |
| except WebDriverException: | |
| print "Exception on {}".format(relativeUrl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment