Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f376223

Browse files
authored
Merge pull request baijum#66 from akabraham/master
Fix tutorial example by clearing input before sending keys
2 parents 257de90 + 5f835de commit f376223

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/getting-started.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ from Python like this.
1818
driver.get("http://www.python.org")
1919
assert "Python" in driver.title
2020
elem = driver.find_element_by_name("q")
21+
elem.clear()
2122
elem.send_keys("pycon")
2223
elem.send_keys(Keys.RETURN)
2324
assert "No results found." not in driver.page_source
@@ -36,7 +37,7 @@ Example Explained
3637

3738
The `selenium.webdriver` module provides all the WebDriver
3839
implementations. Currently supported WebDriver implementations are
39-
Firefox, Chrome, Ie and Remote. The `Keys` class provide keys in the
40+
Firefox, Chrome, IE and Remote. The `Keys` class provide keys in the
4041
keyboard like RETURN, F1, ALT etc.
4142

4243
::
@@ -73,8 +74,11 @@ method. Detailed explanation of finding elements is available in the
7374

7475
Next we are sending keys, this is similar to entering keys using your
7576
keyboard. Special keys can be send using `Keys` class imported from
76-
`selenium.webdriver.common.keys`::
77+
`selenium.webdriver.common.keys`. To be safe, we'll first clear any
78+
prepopulated text in the input field (e.g. "Search") so it doesn't
79+
affect our search results.
7780

81+
elem.clear()
7882
elem.send_keys("pycon")
7983
elem.send_keys(Keys.RETURN)
8084

0 commit comments

Comments
 (0)