-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_script.py
executable file
·55 lines (37 loc) · 1.03 KB
/
test_script.py
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
#!/usr/bin/env python3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
class Amazon:
def __init__(self):
self.driver = webdriver.Firefox()
self.driver.get("http://www.amazon.com")
def open_cart(self):
cart_button = self.driver.find_element_by_id("nav-cart")
cart_button.click()
def close_page(self):
self.driver.close()
class Ebay:
def __init__(self):
self.driver = webdriver.Firefox()
self.driver.get("http://www.ebay.com")
def search(self, search_term):
search_box = self.driver.find_element_by_id("gh-ac")
search_button = self.driver.find_element_by_id("gh-btn")
search_box.send_keys(search_term)
search_button.click()
def close_page(self):
self.driver.close()
if __name__== "__main__":
print("opening amazon")
amazon = Amazon()
print("opening amazon cart")
amazon.open_cart()
print("opening ebay")
ebay = Ebay()
print("searching for skis")
ebay.search("skis")
time.sleep(10)
print("closing web pages");
amazon.close_page()
ebay.close_page()