Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW 3 Max Utrobin #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 56 additions & 9 deletions selenium_selectors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
"""
Add couple selenium tests
1. Submit filled test form
https://demoqa.com/text-box
2. Click on [Code in it] button after selecting new Category
https://testpages.herokuapp.com/styled/basic-ajax-test.html
3. Print all text in Lorem/Ipsum/Dolor columns
https://the-internet.herokuapp.com/challenging_dom#delete
"""
# """
# Add couple selenium tests
# 1. Submit filled test form
# https://demoqa.com/text-box
# 2. Click on [Code in it] button after selecting new Category
# https://testpages.herokuapp.com/styled/basic-ajax-test.html
# 3. Print all text in Lorem/Ipsum/Dolor columns
# https://the-internet.herokuapp.com/challenging_dom#delete
# """
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
# ----------------------------------------------------------------------------------------------
# 1. Submit filled test form
driver = webdriver.Chrome()
driver.get("https://demoqa.com/text-box")
TEST_DATA = {
'full_name': 'Maxim',
'Email': '[email protected]',
'Current_address': 'Wall str. 23',
'Permanent_address': 'Baker str. 12'
}
driver.find_element_by_xpath('//*[@id="userName"]').send_keys(TEST_DATA['full_name'])
driver.find_element_by_xpath('//*[@id="userEmail"]').send_keys(TEST_DATA['Email'])
driver.find_element_by_xpath('//*[@id="currentAddress"]').send_keys(TEST_DATA['Current_address'])
driver.find_element_by_xpath('//*[@id="permanentAddress"]').send_keys(TEST_DATA['Permanent_address'])
driver.find_element_by_xpath('//*[@id="submit"]').click()
assert driver.find_element_by_xpath('//*[@id="output"]')
time.sleep(2)
driver.quit()

# ----------------------------------------------------------------------------------------------
# 2. Click on [Code in it] button after selecting new Category
driver = webdriver.Chrome()
driver.get("https://testpages.herokuapp.com/styled/basic-ajax-test.html")
driver.find_element_by_xpath('//*[@id="combo1"]').click()
driver.find_element_by_xpath('//*[@id="combo1"]/option[3]').click()
driver.find_element_by_xpath('//*[@id="combo2"]').click()
driver.find_element_by_xpath('//*[@id="combo2"]/option[3]').click()
driver.find_element_by_xpath('/html/body/div/div[3]/form/input[1]').click()
time.sleep(2)
assert 'You submitted a form' in driver.page_source
driver.quit()

# ----------------------------------------------------------------------------------------------
# 3. Print all text in Lorem/Ipsum/Dolor columns
driver = webdriver.Chrome()
driver.get("https://the-internet.herokuapp.com/challenging_dom#delete")
elem = driver.find_elements_by_css_selector('tbody tr')
for row in elem:
print((row.find_element_by_css_selector('td:nth-child(1)').text),
(row.find_element_by_css_selector('td:nth-child(2)').text),
(row.find_element_by_css_selector('td:nth-child(3)').text))
driver.quit()