Skip to content

Commit 787685c

Browse files
Ryan MitchellRyan Mitchell
authored andcommitted
Rewrote driver examples
1 parent 7c4c22b commit 787685c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

chapter10/1-seleniumBasic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from selenium import webdriver
22
import time
33

4-
driver = webdriver.PhantomJS(executable_path='')
4+
#REPLACE WITH YOUR DRIVER PATH. EXAMPLES FOR CHROME AND PHANTOMJS
5+
driver = webdriver.PhantomJS(executable_path='../phantomjs-2.1.1-macosx/bin/phantomjs')
6+
#driver = webdriver.Chrome(executable_path='../chromedriver/chromedriver')
57
driver.get("http://pythonscraping.com/pages/javascript/ajaxDemo.html")
6-
time.sleep(3)
8+
time.sleep(5)
79
print(driver.find_element_by_id("content").text)
810
driver.close()

chapter10/2-waitForLoad.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from selenium.webdriver.support.ui import WebDriverWait
33
from selenium.webdriver.support import expected_conditions as EC
44

5-
driver = webdriver.PhantomJS(executable_path='')
5+
#REPLACE WITH YOUR DRIVER PATH. EXAMPLES FOR CHROME AND PHANTOMJS
6+
driver = webdriver.PhantomJS(executable_path='../phantomjs-2.1.1-macosx/bin/phantomjs')
7+
#driver = webdriver.Chrome(executable_path='../chromedriver/chromedriver')
68
driver.get("http://pythonscraping.com/pages/javascript/ajaxDemo.html")
79
try:
810
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "loadedButton")))

chapter10/3-javascriptRedirect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def waitForLoad(driver):
1717
except StaleElementReferenceException:
1818
return
1919

20-
driver = webdriver.PhantomJS(executable_path='<Path to Phantom JS>')
20+
#REPLACE WITH YOUR DRIVER PATH. EXAMPLES FOR CHROME AND PHANTOMJS
21+
driver = webdriver.PhantomJS(executable_path='../phantomjs-2.1.1-macosx/bin/phantomjs')
22+
#driver = webdriver.Chrome(executable_path='../chromedriver/chromedriver')
2123
driver.get("http://pythonscraping.com/pages/javascript/redirectDemo1.html")
2224
waitForLoad(driver)
2325
print(driver.page_source)

0 commit comments

Comments
 (0)