-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelHW.py
More file actions
71 lines (47 loc) · 1.94 KB
/
Copy pathSelHW.py
File metadata and controls
71 lines (47 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
'''Get local session of firefox'''
browser = webdriver.Firefox()
'''Load page : yahoo'''
# browser.get("http://www.yahoo.com")
browser.get("http://international.o2.co.uk/internationaltariffs/calling_abroad_from_uk")
'''error check'''
# assert "Yahoo" in browser.title
# assert "o2" in browser.title
'''interacting with the page'''
'''find query box'''
# elem = browser.find_element_by_name("p")
elem = browser.find_element_by_id("countryName") # Find the query box
'''mimic keystroke interaction with page :input query string and hit return'''
# elem.send_keys("seleniumhq" + Keys.RETURN)
elem.send_keys("Canada" + Keys.RETURN)
'''click the monthly button'''
browser.find_element_by_css_selector('.btn_arrow_tab').click()
# '''retrieve the Base rate'''
# Base = browser.find_element_by_name('base')
# print "this is the Base rate"
# '''retrieve the BoltOnFave3 rate'''
# Base = browser.find_element_by_name('base')
# print "this is the BoltOnFave3 rate"
# '''retrieve the CallCard rate'''
# Base = browser.find_element_by_name('CallCard')
# print "this is the CallCard rate"
'''IDEAS'''
'''feed countries as sys parameters, move through list with list comprehension,
create as keys in default dict for export to excel or JSON format'''
'''build in error checking if required elements are not found on the search page'''
'''error for country not found'''
'''error for Base rate not found'''
'''error for BoltOnFave3 not found'''
'''error for CallCard not found'''
'''pretty print rates for each country / export to Excel spreadsheet???'''
'''Let the page load, will be added to the API'''
time.sleep(0.2)
# '''error catching'''
# try:
# browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
# except NoSuchElementException:
# assert 0, "can't find seleniumhq"
# browser.close()