Created
July 1, 2011 19:10
-
-
Save AutomatedTester/1059183 to your computer and use it in GitHub Desktop.
Using Selenium 2 To type into fields
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
| from selenium import webdriver | |
| from selenium.webdriver.common.keys import Keys | |
| import unittest | |
| class TestHistory(unittest.TestCase): | |
| def setUp(self): | |
| self.driver = webdriver.Firefox() | |
| def tearDown(self): | |
| self.driver.quit() | |
| def test_that_we_can_access_history(self): | |
| self.driver.get("http://localhost:9999/") | |
| input_field = self.driver.find_element_by_id('gcliInput') #Assumed it was an ID | |
| input_field.send_keys("echo there") | |
| input_field.send_keys("O" + Keys.RETURN) | |
| input_field.send_keys("echo there E" + Keys.RETURN) | |
| input_field.send_keys("echo there N" + Keys.RETURN) | |
| input_field.send_keys("&") | |
| self.assertEqual("echo there", input_field.get_attribute("value")) | |
| input_field.send_keys("&") | |
| input_field.send_keys("echo hello (" ) | |
| self.assertEqual("echo there", input_field.get_attribute("value")) | |
| input_field.send_keys("(") | |
| self.assertEqual("", input_field.get_attribute("value")) | |
| input_field.send_keys("(") | |
| self.assertEqual("", input_field.get_attribute("value")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment