class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver = BasePage().get_driver()
        self.driver.get(properties.get_settings()['DEFAULT-BASE-URL'])

    def tearDown(self):
        self.driver.quit()
예제 #2
0
 def test_search_for_category(self):
     base_page = BasePage(self.driver)
     search_page = SearchPage(self.driver)
     
     #navigate to etsy and search for items by category
     assert base_page.nav_to_etsy()
     assert search_page.search_for_category()
예제 #3
0
 def test_search_for_item(self):
     base_page = BasePage(self.driver)
     search_page = SearchPage(self.driver)
     
     #navigate to etsy and search for an item
     assert base_page.nav_to_etsy()
     assert search_page.search_for_item()
예제 #4
0
    def setUp(self):
        self.brower = BasePage()
        '''
		params={"user_token":'market_12'}
		text=rg.request_post("https://fulldev.yjifs.com/tools/tools/get_technical_choose_data?technical_name=KDJ1")
		text_urls=test['datas']
		for url in text_url:
		'''
        self.url = 'http://ad.cjs.com.cn/template/html/81/5b46bbcbcb081.html'
        self.brower.open_url(self.url)
예제 #5
0
class LoginPage:
    # 元素定位, 可放在类里面函数上面
    def __init__(self, driver):
        self.driver = driver
        self.login_locator = LoginLocator()
        self.base_page = BasePage(self.base_page)

    # 登录
    def login(self, user, passwd):
        name = "登录模块"
        self.base_page.wait_element_visible(
            self.login_locator.user_input_xpath, model=name)
        self.base_page.input_text(user,
                                  self.login_locator.user_input_xpath,
                                  model=name)
        self.base_page.input_text(passwd,
                                  self.login_locator.passwd_input_xpath,
                                  model=name)
        self.base_page.click_element(self.login_locator.button_xpath,
                                     model=name)

    def no_data_error(self):
        no_user_locator = (By.XPATH, self.login_locator.no_data_xpath)
        WebDriverWait(self.driver, 30).until(
            EC.visibility_of_all_elements_located(no_user_locator))
        return self.driver.find_element_by_xpath(
            self.login_locator.no_data_xpath).text

    # 注册
    def register(self):
        pass

    # 忘记密码
    def forget_passwd(self):
        pass
예제 #6
0
class Test(unittest.TestCase):
    def setUp(self):
        self.brower = BasePage()
        self.url = 'http://ad.cjs.com.cn/template/html/42/5b46bbc2afd42.html'
        self.brower.open_url(self.url)

    #def tearDown(self):
    # 关闭浏览器
    #self.brower.quit_browser()

    def test_url2(self):
        self.brower.type('//*[@id="mobilePhone"]', 17623250366)
        #self.assertEqual(self.brower.driver.title,u"精准测股系统")
        time.sleep(2)
        self.brower.click("/html/body/div[11]/div/a")
        time.sleep(2)
        '''
		time.sleep(2)
		self.brower.click('//*[@id="btnSave"]')
		self.brower.type('//*[@id="mobilePhone"]',17623250366)
		time.sleep(10)
		#self.brower.d()
		#self.brower.get_page_source()
		#领取
		self.brower.click("/html/body/div[1]/div/div/div/ul/li[3]/button")
		time.sleep(10)
		#已注册弹窗提示
		self.al=self.brower.driver.switch_to.alert
		self.assertEqual(self.al.text,u"已注册手机号!")
		time.sleep(2)
		'''
        self.brower.quit_url()
예제 #7
0
    def test_add_favorite_without_signin(self):
        base_page = BasePage(self.driver)
        search_page = SearchPage(self.driver)

        #navigate to etsy and search for an item
        assert base_page.nav_to_etsy()
        assert search_page.search_for_item("BMW E28 Keychain")

        #retrieve all favorite icons from search results, click the first instance, verify join etsy modal displays
        fav_buttons = self.driver.find_elements_by_xpath(
            "//ul[contains(@class, 'responsive-listing-grid')]" +
            "//li//div[@data-favorite-button-wrapper]//button[contains(@class, 'favorite-listing-button')]"
        )
        fav_buttons[0].click()
        assert self.driver.find_element_by_xpath(
            "//div[@data-join-neu-overlay-container]")
예제 #8
0
class LoginPage():
    def __init__(self, driver: WebDriver):
        self.b = BasePage(driver)

    def login(self, username, password, vec):
        # b = BasePage(driver)
        self.b.send_keys(lp.user_input, username)
        self.b.send_keys(lp.psw_input, password)
        self.b.send_keys(lp.vec_input, vec)
        self.b.click(lp.login_but)

    def error_msg(self):
        return self.b.get_text(lp.error_text)
예제 #9
0
class BaseCase(unittest.TestCase,BaseManager):

    base_page = BasePage()
    @classmethod
    def setUpClass(cls):
        """执行用例前回到首页,同时每个入口记录类名"""
		base_page.default_frame()
        cls.logger = cls.get_logger()
        cls.logger.info("-----执行用例类:" + cls.__name__)
예제 #10
0
 def setUp(self):
     # 设置无头浏览器
     chrome_options = Options()
     chrome_options.add_argument("--headless")
     # 登录
     self.driver = webdriver.Chrome(executable_path=(PD.driver_path),
                                    chrome_options=chrome_options)
     self.driver.maximize_window()
     self.driver.get(public.login_url)
     self.login_page = LoginPage(self.driver)
     self.base_page = BasePage(self.driver)
    def setUp(self):
        paths = ChromeDriverManager().download_and_install()
        self.driver = webdriver.Chrome(paths[0])

        self.base_page = BasePage(self.driver)
        self.home_page = HomePage(self.driver)
        self.flights_page = FlightsPage(self.driver)
        self.seats_page = SeatsPage(self.driver)
        self.home_page_locators = HomePageLocators()
        self.flights_page_locators = FlightsPageLocators()
        self.seats_page_locators = SeatsPageLocators()
        self.extras_page_locators = ExtrasPageLocators()
        self.payment_page_locators = PaymentPageLocators()
        self.login_page_locators = LoginPageLocators()
        self.test_user = TestUser()

        self.driver.maximize_window()
        self.driver.get('http://ryanair.com')
예제 #12
0
파일: product_page.py 프로젝트: atfip/ATFiP
 def __init__(self, browser):
     BasePage.__init__(self, browser)
     page_path = "index.php?m=product&f=browse"
     self.url = self.base_url + page_path
예제 #13
0
 def testShouldCrashIntoFloor(self):
     base_page = BasePage(self.driver)
     base_page.start_game()
     base_page.wait_until_crash()
     self.assertEquals(base_page.helicopter_altitude, 14)
예제 #14
0
 def testShouldCrashIntoCeiling(self):
     base_page = BasePage(self.driver)
     base_page.start_game()
     base_page.engage_thrusters()
     base_page.wait_until_crash()
     self.assertEquals(base_page.helicopter_altitude, 90)
 def setUp(self):
     self.driver = BasePage().get_driver()
     self.driver.get(properties.get_settings()['DEFAULT-BASE-URL'])
예제 #16
0
 def __init__(self, driver):
     self.driver = driver
     self.login_locator = LoginLocator()
     self.base_page = BasePage(self.base_page)
예제 #17
0
 def testShouldCrashIntoFloor(self):
     base_page = BasePage(self.driver)
     base_page.start_game()
     base_page.wait_until_crash()
     self.assertEquals(base_page.helicopter_altitude, 14)
예제 #18
0
class MenuManagement():
    def __init__(self, driver: WebDriver):
        self.b = BasePage(driver)

    def in_menu_manage(self):
        self.b.click(menuloc.sys_manage)
        self.b.click(menu.menu_manage_loc)
        self.b.switch_frame(menu.menu_manage_frame)

    def add_menu(self, name, url, sort):
        self.in_menu_manage()
        self.b.click(menu.add_but)
        self.b.send_keys(menu.name_input, name)
        self.b.send_keys(menu.url_input, url)
        self.b.send_keys(menu.sort_input, sort)
        self.b.click(menu.save_but)

    def delete_menu(self):
        self.b.refresh()  #刷新
        self.in_menu_manage()
        MyLog().info(f"按钮位置:{menu.dele_menu_but}")
        self.b.click(menu().dele_menu_but)
        self.b.accept_alert()
예제 #19
0
 def __init__(self, driver):
     BasePage.__init__(self, driver)
     self.open(login_locators.get("login.url"))
예제 #20
0
 def __init__(self, driver, store_name):
     BasePage.__init__(self, driver)
     self.store_name = store_name
     self.url = "https://%s.shoplo.com/admin" % store_name
예제 #21
0
 def testShouldCrashIntoCeiling(self):
     base_page = BasePage(self.driver)
     base_page.start_game()
     base_page.engage_thrusters()
     base_page.wait_until_crash()
     self.assertEquals(base_page.helicopter_altitude, 90)
예제 #22
0
 def __init__(self, browser):
     BasePage.__init__(self, browser)
     page_path = "index.php?m=user&f=login"
     self.url = self.base_url + page_path
예제 #23
0
 def __init__(self, driver, store_name):
     BasePage.__init__(self, driver)
     self.store_name = store_name
예제 #24
0
 def setUp(self):
     self.brower = BasePage()
     self.url = 'http://ad.cjs.com.cn/template/html/42/5b46bbc2afd42.html'
     self.brower.open_url(self.url)
예제 #25
0
 def __init__(self, driver: WebDriver):
     self.b = BasePage(driver)
예제 #26
0
class Test(unittest.TestCase):
    def setUp(self):
        self.brower = BasePage()
        '''
		params={"user_token":'market_12'}
		text=rg.request_post("https://fulldev.yjifs.com/tools/tools/get_technical_choose_data?technical_name=KDJ1")
		text_urls=test['datas']
		for url in text_url:
		'''
        self.url = 'http://ad.cjs.com.cn/template/html/81/5b46bbcbcb081.html'
        self.brower.open_url(self.url)

    def test_nbsr(self):
        #股票代码输入
        self.brower.type('//*[@id="gp"]', 6)
        self.assertEqual(self.brower.driver.title, u"精准测股系统")
        time.sleep(2)
        self.brower.click(
            "/html/body/div[3]/div[1]/div[2]/div[2]/ul/div/div[1]")
        time.sleep(2)
        self.brower.click('//*[@id="btnSave"]')
        self.brower.type('//*[@id="mobilePhone"]', 17623250366)
        #领取
        self.brower.click("/html/body/div[1]/div/div/div/ul/li[3]/button")
        time.sleep(2)
        #已注册弹窗提示
        self.al = self.brower.driver.switch_to.alert
        self.assertEqual(self.al.text, u"已注册手机号!")
        time.sleep(2)
        self.brower.quit_url()
예제 #27
0
 def __init__(self):
     BasePage.__init__(self)
예제 #28
0
def test_guest(browser, flag, links, buttons, selector, value, selector1,
               value1, selector2, value2, selector3, value3, button_save):
    # browser.get(link)
    # time.sleep(2)
    # browser.find_element_by_id("details-button").click()
    # browser.find_element_by_id("proceed-link").click()
    # # driver.get("http://media.test.itass.local")
    # browser.find_element_by_id("userNameInput").send_keys("ext_kolzin_a")
    # time.sleep(1)
    # browser.find_element_by_id("passwordInput").send_keys("Overlor1")
    # browser.find_element_by_id("submitButton").click()

    page = MainPage(
        browser, links
    )  # инициализируем Page Object, передаем в конструктор экземпляр драйвера и url адрес
    page.open()

    time.sleep(2)
    input = browser.find_element_by_css_selector(buttons)
    input.click()
    time.sleep(1)

    base_page = BasePage(browser, browser.current_url)
    mass_selector = [selector, selector1, selector2, selector3]
    mass_value = [value, value1, value2, value3]

    # input = browser.find_element(By.XPATH, "// *[ @ id = 'root'] / div / div[3] / form / article[1] / section / div / div[1] / label / div / div")
    # input.click()

    if flag == "client":
        input = browser.find_element(
            By.XPATH, "//*[@id='root']/div/div/div/div[3]/form/div[1]/span[2]")
        status = input.text
        assert status == "Анкета не отправлена"

        # переключение на внутреннего клиента
        input = browser.find_element_by_css_selector(
            "label._1B_rCW-HdhdsZBqdHkrllC")
        input.click()

    if flag == "user":
        input = browser.find_element(
            By.XPATH,
            "//*[@id='modal-root']/div/div/section/div/form/div/label")
        status = input.text
        assert status == "Имя Фамилия пользователя"

        # ввод имени полользователя
        input = browser.find_element_by_css_selector("#fullName")
        input.send_keys("Имя")
        # сохранить
        input = browser.find_element_by_css_selector(
            "#modal-root > div > div > section > div > form > button")
        input.click()

        input = browser.find_element_by_css_selector(
            "#modal-root > div > div > section > div > form > div > span")
        mess = input.text
        if mess == "Некорректное значение":
            input = browser.find_element_by_css_selector("#fullName")
            input.send_keys(" Фамилия")
            input = browser.find_element_by_css_selector(
                "#modal-root > div > div > section > div > form > button")
            input.click()

    if flag == "prod":
        input = browser.find_element(
            By.XPATH,
            "//*[@id='product-creating']/section[1]/section/section/div/div[1]/div[2]/div/label"
        )
        status = input.text
        assert status == "Наименование продукта"

        # клик по новый продукт
        # input = browser.find_element_by_css_selector(
        #     "#root > div > div > div > div.MDTTD808z7GuhtYhNCiyx > div._3FtI9K_rYuNqNUawu1Ow7K._2dqkqLWSBZAvRV2i3XPaE1 > header > button")
        # input.click()
        # time.sleep(1)
        input = browser.find_element_by_css_selector(
            "#product-creating > section:nth-child(1) > section > section > div > div:nth-child(2) > div._1BYAPcKJgAVhwLSvxdLQtV._2AYE17bNwF9fAiUDd3jicg._3FlCQKhOHMB0FDq6Lniosb._1CollOa9FvDSi8OuUmm1vf > div > div._1BYAPcKJgAVhwLSvxdLQtV._2AYE17bNwF9fAiUDd3jicg._3FlCQKhOHMB0FDq6Lniosb._1y9E9O3hdI5vdkkrArB_b > div > label"
        )
        input.click()

    i = 0
    for ii in mass_selector:
        time.sleep(2)
        # поля
        browser.find_element_by_css_selector(mass_selector[i]).clear()
        input = browser.find_element_by_css_selector(mass_selector[i])
        input.send_keys(mass_value[i])

        # клик по кнопке сохранить
        input = browser.find_element_by_css_selector(button_save)
        input.click()
        time.sleep(2)
        browser.execute_script('window.scrollTo(0,0);')

        # проверка на наличие надписи "Некорректное значение"
        input1 = browser.find_element_by_class_name("_2BdPeWfKXp-TXCYIUAZiad")
        status1 = input1.text
        assert status1 == "Некорректное значение"
        time.sleep(2)

        # преписка к значению в поле(изменение поля)
        input = browser.find_element_by_css_selector(mass_selector[i])
        input.send_keys("f")

        # base_page = BasePage(browser, browser.current_url)
        if flag == "client":
            assert base_page.is_element_present(By.CLASS_NAME,
                                                "_2BdPeWfKXp-TXCYIUAZiad")

        base_page = BasePage(browser, browser.current_url)
        assert base_page.is_element_present(By.LINK_TEXT,
                                            "Некорректное значение") == False

        # проверка на наличие надписи "Некорректное значение"
        # input1 = browser.find_element_by_class_name("_2BdPeWfKXp-TXCYIUAZiad")
        # status1 = input1.text
        # assert status1 == "Некорректное значение"

        browser.find_element_by_css_selector(mass_selector[i])
        i = i + 1