def test_valid_info(self):
        self.test_register_page()
        input_username=init.find_element_by_id(self.driver,'username')
        init.send_input(self.driver,input_username,"automation_test")
        input_email=init.find_element_by_id(self.driver,'email')
        init.send_input(self.driver,input_email,"*****@*****.**")
        input_password=init.find_element_by_id(self.driver,'password')
        init.send_input(self.driver,input_password,"123456")
        init.find_element_by_xpath(self.driver,"/html/body/div[1]/div/div/form/div[4]/button[1]").click()

        # check alert
        try:
            time.sleep(2)
            alertBox = self.driver.switch_to_window()
            # print (type(alert))
            alertBox.accept()
            print("alert accepted")
        except NoAlertPresentException:
            pass
 def test_search_non_sensitive_church(self):
     init.navigate_to_website(
         self.driver, "https://ningpekin.github.io/BlueWhaleMontreal")
     element = init.find_element_by_id(self.driver, "input-0")
     init.send_input(self.driver, element, "cHUrch")
     button = init.find_element_by_xpath(
         self.driver,
         "/html/body/section[1]/div/table/tbody/tr/td[2]/div/button")
     button.click()
     # test title--if website redirect?
     new_web_title = self.driver.title
     self.assertEqual(new_web_title, "Blue Whale Montreal")
Example #3
0
def function_to_be_tested(username, email, password,button):
    # do something
    driver = init.init_firefox_driver("/home/ning/PycharmProjects/testBlueWhale/geckodriver")
    driver.implicitly_wait(100)
    init.navigate_to_website(driver, "https://ningpekin.github.io/BlueWhaleMontreal")
    btn_register = init.find_element_by_xpath(driver, "/html/body/nav/div/div/ul/li[3]/a")
    btn_register.click()
    input_username=init.find_element_by_id(driver,'username')
    init.send_input(driver,input_username,username)
    input_email=init.find_element_by_id(driver,'email')
    init.send_input(driver,input_email,email)
    input_password=init.find_element_by_id(driver,'password')
    init.send_input(driver,input_password,password)
    if(button=="done"):
        btn_done=init.find_element_by_xpath(driver,"/html/body/div[1]/div/div/form/div[4]/button[1]")
        btn_done.click()

    elif(button=="cancel"):
        btn_cancle=init.find_element_by_class(driver,button)
        btn_cancle.click()
        assert (driver.current_url=="https://ningpekin.github.io/BlueWhaleMontreal/")

    driver.close()
 def test_search_church(self):
     init.navigate_to_website(
         self.driver, "https://ningpekin.github.io/BlueWhaleMontreal")
     element = init.find_element_by_id(self.driver, "input-0")
     init.send_input(self.driver, element, "Church")
     result = init.find_element_by_xpath(
         self.driver,
         "/html/body/md-virtual-repeat-container/div/div[2]/ul/li").text
     # test serach result in hint
     self.assertEqual("Church", result)
     button = init.find_element_by_xpath(
         self.driver,
         "/html/body/section[1]/div/table/tbody/tr/td[2]/div/button")
     button.click()
     # test title--if website redirect correcttly
     new_web_title = self.driver.title
     self.assertEqual(new_web_title, "Church List")
 def test_search_unvalide(self):
     input = "People"
     init.navigate_to_website(
         self.driver, "https://ningpekin.github.io/BlueWhaleMontreal")
     element = init.find_element_by_id(self.driver, "input-0")
     init.send_input(self.driver, element, input)
     result = init.find_element_by_xpath(
         self.driver,
         "/html/body/md-virtual-repeat-container/div/div[2]/ul/li").text
     # test serach result in hint
     input1 = 'No lists matching "People" were found.'
     self.assertEqual(input1, result)
     button = init.find_element_by_xpath(
         self.driver,
         "/html/body/section[1]/div/table/tbody/tr/td[2]/div/button")
     button.click()
     web_title = self.driver.title
     # no change web page
     self.assertEqual(web_title, "Blue Whale Montreal")
Example #6
0
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import init as init

driver = init.init_firefox_driver(
    "/home/ning/PycharmProjects/testBlueWhale/geckodriver")
init.navigate_to_website(driver,
                         "https://ningpekin.github.io/BlueWhaleMontreal")
# driver.wait = WebDriverWait(driver, 1000)
element = init.find_element_by_id(driver, "input-0")
init.send_input(driver, element, "Metro")
element = init.find_element_by_xpath(
    driver, "/html/body/section[1]/div/table/tbody/tr/td[2]/div/button")
element.click()
driver.implicitly_wait(30)
driver.close()