Selenium: Difference between revisions

Content added Content deleted
 
Line 18: Line 18:
export GECKO_DRIVER_VERSION='v0.29.0'
export GECKO_DRIVER_VERSION='v0.29.0'


= Using Self Signed Certificates =
= Sample Code =
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
from selenium import webdriver
from selenium import webdriver
Line 35: Line 35:


browser.close()
browser.close()
</syntaxhighlight>

= Testing reachability =

<syntaxhighlight lang="python">
#!/usr/bin/env python

import unittest
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

class TestUbuntuHomepage(unittest.TestCase):

def setUp(self):
options = Options()
options.add_argument("--headless")
self.browser = webdriver.Firefox(options=options)

def testTitle(self):
self.browser.get('http://www.ubuntu.com/')
self.assertIn('Ubuntu', self.browser.title)

def tearDown(self):
self.browser.quit()


if __name__ == '__main__':
unittest.main(verbosity=2)
</syntaxhighlight>
</syntaxhighlight>