Skip to content

Instantly share code, notes, and snippets.

@chatrapathik
Created August 12, 2017 11:57
Show Gist options
  • Save chatrapathik/d714bbd7ab5b2fd3fe30e91cea19ac32 to your computer and use it in GitHub Desktop.
Save chatrapathik/d714bbd7ab5b2fd3fe30e91cea19ac32 to your computer and use it in GitHub Desktop.
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class ExampleTests(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
def test_google_without_send_keys(self):
self.driver.get("http://www.google.com")
input_box = self.driver.find_element_by_id('lst-ib')
assert "Google" in self.driver.title
self.driver.save_screenshot('google.png')
def test_google_with_send_keys(self):
self.driver.get("http://www.google.com")
input_box = self.driver.find_element_by_id('lst-ib')
input_box.send_keys('apple', Keys.RETURN)
assert "Google" in self.driver.title
self.driver.save_screenshot('google.png')
def tearDown(self):
self.driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment