-
Notifications
You must be signed in to change notification settings - Fork 0
/
seleniumPractice.py
51 lines (40 loc) · 1.34 KB
/
seleniumPractice.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 19 22:18:52 2017
@author: mmonforte
"""
from selenium import webdriver
import time, credentials
browser = webdriver.Chrome()
browser.get('http://gmail.com')
try:
"""
# This section was to test identification of element names.
browser.get('http://gmail.com')
elem = browser.find_element_by_class_name('bookcover')
print('Found <%s> element with that class name!' % (elem.tag_name))
"""
"""
# This section was testing page clicks.
browser.get('http://gmail.com')
linkElem = browser.find_element_by_link_text('Read It Online')
linkElem.click()
"""
# This section is testing forms, clicks, and submissions.
waitTime = 2
browser.get('http://gmail.com')
time.sleep(waitTime)
emailElem = browser.find_element_by_id('identifierId')
emailElem.send_keys(credentials.gmail_username)
time.sleep(waitTime)
nextButtonElem = browser.find_element_by_id('identifierNext')
nextButtonElem.click()
time.sleep(waitTime)
passwordElem = browser.find_element_by_name('password')
passwordElem.send_keys(credentials.gmail_password)
time.sleep(waitTime)
passwordButton = browser.find_element_by_id('passwordNext')
passwordButton.click()
except:
print('Request failed.')