Notes
Notes - notes.io |
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.support.ui import Select
import HtmlTestRunner
class Submit(unittest.TestCase):
def setUp(self):
service = Service("/home/pg_user/Desktop/geckodriver")
self.driver = webdriver.Firefox(service=service)
self.driver.implicitly_wait(10)
self.driver.get("http://localhost:8080/application/sample.htm")
print(self.driver.title)
self.driver.maximize_window()
def testName(self): # must start with 'test'
driver = self.driver
driver.find_element(By.LINK_TEXT, "Login").click()
driver.find_element(
By.XPATH, "//input[@placeholder='Enter User Name']"
).send_keys("admin")
driver.find_element(
By.XPATH, "//input[@placeholder='Enter password']"
).send_keys("infy123")
driver.find_element(
By.XPATH, "//button[text()='Login']"
).click()
driver.find_element(
By.XPATH, "//button[text()='Add Chemicals']"
).click()
Select(driver.find_element(
By.XPATH, "//select[@name='chemType']"
)).select_by_visible_text("Toxic")
driver.find_element(
By.XPATH, "//input[@name='chemName']"
).send_keys("HydrogenChloride")
driver.find_element(
By.XPATH, "//input[@name='casNumber']"
).send_keys("7647010")
driver.find_element(
By.XPATH, "//input[@name='quantity']"
).send_keys("2000")
driver.find_element(
By.XPATH, "//button[text()='Add Chemicals']"
).click()
print(driver.find_element(
By.XPATH, "//div[contains(@class,'alert')]"
).text)
driver.find_element(
By.XPATH, "//button[text()='View Updated Chemical']"
).click()
headers = driver.find_elements(
By.XPATH, "//table/thead/tr/th"
)
header_names = [h.text for h in headers]
rows = driver.find_elements(
By.XPATH, "//table/tbody/tr"
)
for row in rows:
cols = row.find_elements(By.XPATH, "td")
if len(cols) > 0 and cols[0].text == "Acetaldehyde":
for i, col in enumerate(cols):
print(f"{header_names[i]} : {col.text}")
break
driver.save_screenshot(
"/home/pg_user/Desktop/ToxicChemicals.PNG"
)
total_rows = driver.find_elements(
By.XPATH, "//table/tbody/tr"
)
self.assertEqual(len(total_rows), 4,
f"Expected 4 rows but found {len(total_rows)}")
def tearDown(self):
self.driver.quit()
if __name__ == "__main__":
unittest.main(
testRunner=HtmlTestRunner.HTMLTestRunner(output="reports")
)
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
