-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaula_07_1.py
More file actions
48 lines (30 loc) · 1.33 KB
/
aula_07_1.py
File metadata and controls
48 lines (30 loc) · 1.33 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
from selenium.webdriver import Firefox
from selenium.webdriver.support.events import (
AbstractEventListener,
EventFiringWebDriver
)
class Escuta(AbstractEventListener):
def before_navigate_to(self, url, webdriver):
print(f'Indo para {url}')
def after_navigate_back(self, url):
print('voltando para a página anterior...')
def before_click(self, elemento, webdriver):
if elemento.tag_name == 'input':
print(webdriver.find_element_by_tag_name('span').text)
print(f'Antes do click {elemento.tag_name}')
def after_click(self, elemento, webdriver):
if elemento.tag_name == 'input':
print(webdriver.find_element_by_tag_name('span').text)
print(webdriver.find_element_by_tag_name('span').text)
print(f'depois do click {elemento.tag_name}')
browser = Firefox(executable_path="./geckodriver")
# Wrapper do WebDriver
rapidez = EventFiringWebDriver(browser, Escuta())
rapidez.get('https://selenium.dunossauro.live/aula_07_d.html')
input_texto = rapidez.find_element_by_tag_name('input')
span = rapidez.find_element_by_tag_name('span')
p = rapidez.find_element_by_tag_name('p')
input_texto.click()
rapidez.get('https://selenium.dunossauro.live/aula_07_c.html')
rapidez.back()
browser.quit()