forked from dunossauro/live-de-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle.py
More file actions
33 lines (26 loc) · 855 Bytes
/
google.py
File metadata and controls
33 lines (26 loc) · 855 Bytes
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
"""Exemplo de PO no google.com."""
from selenium import webdriver
class Google:
def __init__(self, driver):
self.driver = driver
self.url = 'http://google.com.br'
self.search_bar = 'lst-ib' # id
self.btn_search = 'btnK' # name
self.btn_lucky = 'btnI' # name
def navigate(self):
self.driver.get(self.url)
def search(self, word='None'):
self.driver.find_element_by_id(
self.search_bar).send_keys(word)
self.driver.find_element_by_name(
self.btn_search).click()
def lucky(self, word='None'):
self.driver.find_element_by_id(
self.search_bar).send_keys(word)
self.driver.find_element_by_name(
self.btn_lucky).click()
ff = webdriver.Firefox()
g = Google(ff)
g.navigate()
g.lucky('Live de Python')
ff.quit()