-
Notifications
You must be signed in to change notification settings - Fork 0
/
contatoSH.py
executable file
·64 lines (48 loc) · 2.13 KB
/
contatoSH.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
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# https://selenium-python.readthedocs.io/getting-started.html
# http://stackoverflow.com/questions/25537567/how-to-open-website-and-fill-in-input-using-selenium-webdriver#25537644
# The selenium.webdriver module provides all the WebDriver implementations.
# Currently supported WebDriver implementations are Firefox, Chrome, IE and Remote.
from selenium import webdriver
# The Keys class provide keys in the keyboard like RETURN, F1, ALT etc.
from selenium.webdriver.common.keys import Keys
# provides useful methods for interacting HTML <select> element
from selenium.webdriver.support.ui import Select
# Next, the instance of Firefox WebDriver is created.
driver = webdriver.Firefox()
# The driver.get method will navigate to a page given by the URL
driver.get("http://semhora.com.br/contato")
# The next line is an assertion to confirm that title has “Python” word in it:
assert "app" in driver.title
# preenche o campo Seu nome
name = driver.find_element_by_id("name")
name.send_keys('Maria da Silva')
name.submit()
# preenche o campo Seu email
name = driver.find_element_by_id("email")
name.send_keys('[email protected]')
name.submit()
# preenche o campo Seu Seu telefone
phone = driver.find_element_by_id("phone")
phone.send_keys('11 97654 5682')
phone.submit()
# preenche o campo Qual evento?
evento = driver.find_element_by_id("event")
evento.send_keys('Event')
evento.submit()
# imprime todos os valores do <select> Assunto
element = driver.find_element_by_id("subject")
all_options = element.find_elements_by_tag_name("option")
for option in all_options:
print("Value is: %s" % option.get_attribute("value"))
option.click()
# preenche o campo Mensagem
mensagem = driver.find_element_by_id("message")
mensagem.send_keys('Lorem Ipsum Generator provides a GTK+ graphical user interface, a command-line interface, and a Python module that generate random "lorem ipsum" text (a popular kind of dummy text). ')
mensagem.submit()
select = Select(driver.find_element_by_name('subject'))
# select.select_by_index(index)
# select.select_by_visible_text("text")
select.select_by_value('Reclamação')
driver.quit()