-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9735591
Showing
18 changed files
with
591 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Selenium Automation Many projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.select import Select | ||
from time import sleep | ||
|
||
class DropDownList(): | ||
|
||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/p/practice' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.get(baseUrl) | ||
driver.implicitly_wait(10) | ||
|
||
element = driver.find_element(By.ID, 'carselect') | ||
sel = Select(element) | ||
sel.select_by_value('benz') | ||
print('select benz by value') | ||
sleep(2) | ||
|
||
sel.select_by_index('2') | ||
print('select honda by index') | ||
sleep(2) | ||
|
||
sel.select_by_visible_text('BMW') | ||
print('select BMW by visible_text') | ||
sleep(2) | ||
|
||
sel.select_by_index(2) | ||
print('select honda by index - 2') | ||
sleep(2) | ||
|
||
|
||
|
||
|
||
ff = DropDownList() | ||
ff.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from time import sleep | ||
|
||
class RadioAndCheckForLoop(): | ||
|
||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/p/practice' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.get(baseUrl) | ||
driver.implicitly_wait(10) | ||
|
||
radioList = driver.find_elements(By.XPATH, '//*[@type="radio"]') | ||
size = len(radioList) | ||
print('Radio list: ' + str(size)) | ||
for radio in radioList: | ||
isSelected = radio.is_selected() | ||
if not isSelected: | ||
radio.click() | ||
sleep(1) | ||
|
||
checkList = driver.find_elements(By.XPATH, '//*[@type="checkbox"]') | ||
size = len(checkList) | ||
print('Radio list: ' + str(size)) | ||
for check in checkList: | ||
isSelected = check.is_selected() | ||
if not isSelected: | ||
check.click() | ||
sleep(1) | ||
|
||
|
||
|
||
ff = RadioAndCheckForLoop() | ||
ff.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.select import Select | ||
from time import sleep | ||
|
||
class GetText(): | ||
|
||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/p/practice' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.get(baseUrl) | ||
driver.implicitly_wait(10) | ||
|
||
openTabElement = driver.find_element_by_id('opentab') | ||
element_text = openTabElement.text | ||
print(element_text) | ||
sleep(3) | ||
|
||
|
||
|
||
|
||
ff = GetText() | ||
ff.test() |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import sys | ||
from time import sleep | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')) | ||
from utilities.handy_wrappers import HandyWrappers | ||
|
||
|
||
|
||
class Element_Preset_Check(): | ||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/p/practice' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.implicitly_wait(10) | ||
hw = HandyWrappers(driver) | ||
driver.get(baseUrl) | ||
|
||
Element_Preset = hw.isElementPresent("//input[@id='name']", By.XPATH) | ||
print(Element_Preset) | ||
sleep(3) | ||
Element_Preset1 = hw.elementPresenceCheck('name', By.ID) | ||
print(Element_Preset1) | ||
sleep(3) | ||
|
||
|
||
ff = Element_Preset_Check() | ||
ff.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from time import sleep | ||
|
||
class ClickAndSendKeys(): | ||
|
||
def test(self): | ||
baseUrl = 'https://www.google.com/' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.get(baseUrl) | ||
|
||
searchKeys = driver.find_element(By.NAME, 'q') | ||
searchKeys.send_keys('Bangladesh') | ||
sleep(3) | ||
|
||
ff = ClickAndSendKeys() | ||
ff.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
class HandyWrappers(): | ||
|
||
def __init__(self, driver): | ||
self.driver = driver | ||
|
||
def getByType(self, locatorType): | ||
locatorType = locatorType.lower() | ||
if locatorType == "id": | ||
return By.ID | ||
elif locatorType == "name": | ||
return By.NAME | ||
elif locatorType == "xpath": | ||
return By.XPATH | ||
elif locatorType == "css": | ||
return By.CSS_SELECTOR | ||
elif locatorType == "classname": | ||
return By.CLASS_NAME | ||
elif locatorType == "linktext": | ||
return By.LINK_TEXT | ||
else: | ||
print("Locator type " + locatorType + " not correct/supported") | ||
return False | ||
|
||
def getElement(self, locator, locatorType="id"): | ||
element = None | ||
try: | ||
locatorType = locatorType.lower() | ||
byType = self.getByType(locatorType) | ||
element = self.driver.find_element(byType, locator) | ||
print("Element Found") | ||
except: | ||
print("Element not found") | ||
return element | ||
|
||
def isElementPresent(self, locator, byType): | ||
try: | ||
element = self.driver.find_element(byType, locator) | ||
if element is not None: | ||
print("Element Found") | ||
return True | ||
else: | ||
print("Element not found") | ||
return False | ||
except: | ||
print("Element not found") | ||
return False | ||
|
||
def elementPresenceCheck(self, locator, byType): | ||
try: | ||
elementList = self.driver.find_elements(byType, locator) | ||
if len(elementList) > 0: | ||
print("Element Found") | ||
return True | ||
else: | ||
print("Element not found") | ||
return False | ||
except: | ||
print("Element not found") | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import sys | ||
from time import sleep | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')) | ||
from utilities.handy_wrappers import HandyWrappers | ||
|
||
|
||
class Login(): | ||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.implicitly_wait(10) | ||
hw = HandyWrappers(driver) | ||
driver.get(baseUrl) | ||
|
||
# logins = hw.getElement("//a[contains(text(),'Login')]", locatorType='xpath') | ||
# #logins = driver.find_element_by_xpath("//a[contains(text(),'Login')]") | ||
# logins.click() | ||
# sleep(5) | ||
|
||
# email = hw.getElement('user_email', locatorType='id') | ||
# email.send_keys('[email protected]') | ||
# sleep(3) | ||
|
||
# password = hw.getElement('user_password', locatorType='id') | ||
# password.send_keys('abcabc') | ||
# sleep(3) | ||
# loginButton = hw.getElement('commit', locatorType='name') | ||
# loginButton.click() | ||
# sleep(10) | ||
viewAll = hw.getElement("//a[contains(text(),'View All Courses')]", locatorType='xpath') | ||
viewAll.click() | ||
sleep(5) | ||
|
||
cource = "//div[contains(@class, 'course-listing-title') and contains(text(), '{0}')]" | ||
courceLocator = cource.format('JavaScript for beginners') | ||
courceElement = driver.find_element(By.XPATH, courceLocator) | ||
courceElement.click() | ||
sleep(4) | ||
|
||
ff = Login() | ||
ff.test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from selenium.webdriver import Chrome, ChromeOptions | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
import csv | ||
|
||
options = ChromeOptions() | ||
options.headless = True | ||
driver = Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe", | ||
options=options) | ||
|
||
driver.get('https://directory.ntschools.net/#/schools') | ||
selector = '//a[@click.delegate="schoolDetails(school)"]' | ||
links = WebDriverWait(driver, 60).until( | ||
EC.presence_of_all_elements_located((By.XPATH, selector)) | ||
) | ||
#results = [] | ||
school_name_selector = '//div[@class="school-title"]/h1' | ||
for i in range(3): | ||
links = WebDriverWait(driver, 60).until( | ||
EC.presence_of_all_elements_located((By.XPATH, selector)) | ||
) | ||
links[i].click() | ||
name_e = WebDriverWait(driver, 60).until( | ||
EC.presence_of_element_located((By.XPATH, school_name_selector)) | ||
) | ||
name_e.text | ||
# details = { | ||
# 'name': name_e.text, | ||
# 'ph_address': driver.find_element_by_xpath('//div[text()="Physical Address"]/following-sibling::div').text, | ||
# 'po_address': driver.find_element_by_xpath('//*[text()="Postal Address"]/following-sibling::*').text, | ||
# 'phone': driver.find_element_by_xpath('//*[text()="Phone"]/following-sibling::*/a').text, | ||
# } | ||
# results.append(details) | ||
driver.back() | ||
driver.quit() | ||
|
||
# with open('schools_data.csv', 'w', newline='', encoding='utf-8') as f: | ||
# writer = csv.DictWriter(f, | ||
# fieldnames=['name', 'ph_address', 'po_address', 'phone']) | ||
# writer.writeheader() | ||
# writer.writerows(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from time import sleep | ||
|
||
class RadioBatton(): | ||
|
||
def test(self): | ||
baseUrl = 'https://letskodeit.teachable.com/p/practice' | ||
driver = webdriver.Chrome(executable_path="G:\Projects\SeleNium\chromedriver.exe") | ||
driver.maximize_window() | ||
driver.get(baseUrl) | ||
driver.implicitly_wait(10) | ||
|
||
radio = driver.find_element(By.ID, 'benzradio') | ||
radio.click() | ||
sleep(1) | ||
|
||
radio1 = driver.find_element_by_xpath("//input[@id='bmwradio']") | ||
radio1.click() | ||
sleep(1) | ||
|
||
radio2 = driver.find_element(By.ID, 'hondaradio') | ||
radio2.click() | ||
sleep(1) | ||
|
||
check1 = driver.find_element(By.ID, 'bmwcheck') | ||
check1.click() | ||
sleep(1) | ||
|
||
check2 = driver.find_element(By.ID, 'benzcheck') | ||
check2.click() | ||
sleep(1) | ||
|
||
check3 = driver.find_element(By.ID, 'hondacheck') | ||
check3.click() | ||
sleep(1) | ||
|
||
print("BMW radio Button is selected? " + str(radio1.is_selected())) | ||
print("BMW radio Button is selected? " + str(radio2.is_selected())) | ||
print("BMW radio Button is selected? " + str(radio.is_selected())) | ||
|
||
|
||
print("BMW radio Button is Checked? " + str(check1.is_selected())) | ||
print("BMW radio Button is Checked? " + str(check2.is_selected())) | ||
print("BMW radio Button is Checked? " + str(check3.is_selected())) | ||
|
||
|
||
|
||
|
||
ff = RadioBatton() | ||
ff.test() |
Oops, something went wrong.