示例#1
0
    def test_windows(self):
        try:
            self.log = self.getLogger()
            self.wind = HomePage(self.driver)
            self.wind.home("Multiple Windows", 5)
            self.log.info("Opened page successfully")

            self.driver.find_element_by_xpath(
                '//a[text()="Click Here"]').click()

            if len(self.driver.window_handles) == 2:
                self.log.info("New window opened")
            else:
                self.log.error("Window nt opened")
                assert False

            self.driver.switch_to.window(self.driver.window_handles[1])
            if "New Window" in self.driver.find_element_by_xpath('//h3').text:
                self.log.info("Window switched successfully")
            else:
                self.log.critical("Window not switched")
                assert False

            self.driver.switch_to.window(self.driver.window_handles[0])
            if "Opening a new window" in self.driver.find_element_by_xpath(
                    '//h3').text:
                self.log.info("Window switched successfully")
            else:
                self.log.critical("Window not switched")
                assert False

        except:
            self.log.error(sys.exc_info())
            assert False
示例#2
0
    def test_inputs(self):
        try:
            self.log = self.getLogger()
            self.inputs = HomePage(self.driver)
            self.inputs.home("Inputs", 5)
            self.driver.find_element_by_xpath(
                '//input[@type="number"]').click()
            self.action = ActionChains(self.driver)

            self.action.send_keys(Keys.UP).perform()
            self.original = self.driver.find_element_by_xpath(
                '//input[@type="number"]').text

            sleep(2)

            self.action.send_keys(Keys.UP).perform()
            self.final = self.driver.find_element_by_xpath(
                '//input[@type="number"]').text

            sleep(2)

            self.log.info("Working fine")

        except:
            self.log.error(sys.exc_info())
            assert False
示例#3
0
    def test_key_presses(self):
        try:
            self.log=self.getLogger()
            self.key=HomePage(self.driver)
            self.key.home("Key Presses",5)
            self.log.info("Page opened successfully")

            self.action=ActionChains(self.driver)
            self.action.send_keys(Keys.UP).perform()
            if "You entered: UP" in self.driver.find_element_by_xpath('//p[@id="result"]').text:
                self.log.info("UP Key detected successfully")
            else:
                self.log.critical("Key not detected")
                assert False

            self.action.send_keys(Keys.DOWN).perform()
            if "You entered: DOWN" in self.driver.find_element_by_xpath('//p[@id="result"]').text:
                self.log.info("DOWN Key detected successfully")
            else:
                self.log.critical("Key not detected")
                assert False



        except:
            self.log.error(sys.exc_info())
            assert False
示例#4
0
    def test_upload_file(self):
        try:
            self.log = self.getLogger()
            self.upload = HomePage(self.driver)
            self.upload.home("File Upload", 10)
            self.log.info("FIle upload page opened")
            self.driver.implicitly_wait(10)
            self.loc = "C:\\Users\\Anmol\\Downloads\\Sample.pdf"
            self.log.info("Location successfully picked")
            self.choose = self.driver.find_element_by_xpath(
                '//input[@id="file-upload"]')
            self.log.info("The Choose File button selected")
            self.choose.send_keys(self.loc)
            self.log.info("Value sent to the button")
            sleep(5)
            self.driver.find_element_by_xpath(
                '//input[@id="file-submit"]').click()
            self.log.info("Clicked on Upload button")
            self.driver.implicitly_wait(5)
            if "File Uploaded!" in self.driver.find_element_by_xpath(
                    '//h3').text:
                self.log.info("File uploaded successfully")
            else:
                self.log.error("File not uploaded successfully")

        except:
            self.log.error(sys.exc_info())
            assert False
示例#5
0
    def test_hovers(self):
        try:
            self.log = self.getLogger()
            self.hovers = HomePage(self.driver)
            self.action = ActionChains(self.driver)
            self.hovers.home("Hovers", 10)
            self.img1 = self.driver.find_element_by_xpath(
                '//*[@id="content"]/div/div[1]/img')
            self.img2 = self.driver.find_element_by_xpath(
                '//*[@id="content"]/div/div[2]/img')
            self.img3 = self.driver.find_element_by_xpath(
                '//*[@id="content"]/div/div[3]/img')

            self.action.move_to_element(self.img1).perform()
            self.log.info(
                self.img1.find_element_by_xpath(
                    '//*[@id="content"]/div/div[1]/div/h5').text)

            self.action.move_to_element(self.img2).perform()
            self.log.info(
                self.img2.find_element_by_xpath(
                    '//*[@id="content"]/div/div[2]/div/h5').text)

            self.action.move_to_element(self.img3).perform()
            self.log.info(
                self.img3.find_element_by_xpath(
                    '//*[@id="content"]/div/div[3]/div/h5').text)

        except:
            self.log.error(sys.exc_info())
            assert False
示例#6
0
    def test_formauthentication(self):
        try:
            self.log = self.getLogger()
            self.form_auth = HomePage(self.driver)
            self.form_auth.home("Form Authentication", 5)
            self.driver.find_element_by_xpath(
                '//input[@name="username"]').send_keys("tomsmith")
            self.driver.find_element_by_xpath(
                '//input[@name="password"]').send_keys("SuperSecretPassword!")
            self.driver.find_element_by_xpath(
                '//button[@type="submit"]').click()
            self.driver.implicitly_wait(10)
            if "You logged into a secure area!" in self.driver.find_element_by_xpath(
                    '//div[@class="flash success"]').text:
                self.log.info("Logged in successfully!")
                self.driver.find_element_by_xpath(
                    '//a[@class="button secondary radius"]').click()
                self.driver.implicitly_wait(10)
                if "You logged out of the secure area!" in self.driver.find_element_by_xpath(
                        '//div[@class="flash success"]').text:
                    self.log.info("Logged out successfully!")
                else:
                    self.log.critical("Error while logging out")

            else:
                self.log.critical("There was error in logging in")

        except:
            self.log.error(sys.exc_info())
            assert False
示例#7
0
    def test_infinite_class(self):
        '''Method for infinite scroll'''
        try:
            self.log = self.getLogger()
            self.scroll = HomePage(self.driver)
            self.scroll.home("Infinite Scroll", 5)
            self.scroll_time = 2
            self.last_height = self.driver.execute_script(
                "return document.body.scrollHeight")
            self.count = 1

            while True:
                self.driver.execute_script(
                    "window.scrollTo(0, document.body.scrollHeight)")
                self.log.info("Scrolled " + str(self.count) + " times")
                self.count += 1
                sleep(self.scroll_time)
                self.new_height = self.driver.execute_script(
                    "return document.body.scrollHeight")
                if self.new_height == self.last_height or self.count == 15:
                    break

                self.last_height = self.new_height

        except:
            self.log.error(sys.exc_info())
            assert False
示例#8
0
 def test_download(self):
     try:
         self.log=self.getLogger()
         self.down=HomePage(self.driver)
         self.down.home("File Download",10)
         self.driver.find_element_by_xpath('//a[text()="some-file.txt"]').click()
         self.log.info("First file downloaded")
     except:
         self.log.error(sys.exc_info())
         assert False
示例#9
0
    def test_dropdown(self):
        try:
            self.log = self.getLogger()
            self.dropdown = HomePage(self.driver)
            self.dropdown.home('Dropdown', 5)
            self.dropAttr = (By.XPATH, '//select[@id="dropdown"]/option[text()="Option 1"]')
            self.driver.find_element(*self.dropAttr).click()
            self.log.info("Option selected from the dropdown and hence the case is completed!")

        except:
            self.log.error(sys.exc_info())
示例#10
0
    def test_dragdAndDrop(self):
        try:
            self.log = self.getLogger()
            self.dragdrop = HomePage(self.driver)
            self.dragdrop.home('Drag and Drop', 5)
            self.div1 = self.driver.find_element_by_xpath(
                '//div[@id="column-a"]')
            self.div2 = self.driver.find_element_by_xpath(
                '//div[@id="column-b"]')
            self.action = ActionChains(self.driver)
            self.action.drag_and_drop(self.div2, self.div1).perform()
            self.log.info("Drag and Drop completed!")

        except:
            self.log.error(sys.exc_info())
示例#11
0
    def test_geolocation(self):
        try:
            self.log = self.getLogger()
            self.geo = HomePage(self.driver)
            self.geo.home("Geolocation", 10)
            self.driver.find_element_by_xpath('//button[text()="Where am I?"]').click()
            self.log.info("Clicked the 'Where am I?' button")
            self.driver.implicitly_wait(5)
            self.lat = self.driver.find_element_by_xpath('//div[@id="lat-value"]').text
            self.long = self.driver.find_element_by_xpath('//div[@id="long-value"]').text
            self.log.info("Latitude: " + self.lat)
            self.log.info("Longitude: " + self.long)
            self.driver.close()

        except:
            self.log.error(sys.exc_info())
            assert False
示例#12
0
class TestAlerts(BaseClass):
    def test_alerts(self):
        try:
            self.log = self.getLogger()
            self.alert = HomePage(self.driver)
            self.alert.home("JavaScript Alerts", 5)

            self.log.info("First Button")
            self.driver.find_element_by_xpath('//button[text()="Click for JS Alert"]').click()

            self.alert_obj = self.driver.switch_to.alert
            self.log.info("Alert box text is: " + self.alert_obj.text)
            sleep(2)
            self.alert_obj.accept()
            self.log.info("Here")
            sleep(2)

            if "You successfully clicked an alert" in self.driver.find_element_by_xpath('//p[@id="result"]').text:
                self.log.info("First alert working fine.")
            else:
                self.log.critical("First alert not working")

            self.log.info("Second Button")
            self.driver.find_element_by_xpath('//button[text()="Click for JS Confirm"]').click()
            self.log.info("Alert box text is: " + self.alert_obj.text)
            self.alert_obj.dismiss()
            if "You clicked: Cancel" in self.driver.find_element_by_xpath('//p[@id="result"]').text:
                self.log.info("Second alert working fine.")
            else:
                self.log.critical("Second alert not working")

            self.log.info("Third Button")
            self.driver.find_element_by_xpath('//button[text()="Click for JS Prompt"]').click()
            self.log.info("Alert box text is: " + self.alert_obj.text)
            self.alert_obj.send_keys("Sample")
            self.alert_obj.accept()
            if "You entered: Sample" in self.driver.find_element_by_xpath('//p[@id="result"]').text:
                self.log.info("Third alert working fine.")
            else:
                self.log.critical("Third alert not working")


        except:
            self.log.error(sys.exc_info())
            assert False
示例#13
0
    def test_DynamicContent(self):
        try:
            self.log = self.getLogger()
            self.dynamic = HomePage(self.driver)
            self.dynamic.home('Dynamic Content', 5)
            self.row = (By.XPATH, '//div[@class="large-10 columns"]')

            for i in range(2):
                self.rowSelect = self.driver.find_elements(*self.row)
                self.log.warning(self.rowSelect)
                self.j = 0
                for j in range(3):
                    self.rowContent = self.rowSelect[j].text
                    self.log.info(self.rowContent)

                self.driver.refresh()

        except:
            self.log.error(sys.exc_info())
示例#14
0
    def test_nestedframes(self):
        try:
            self.log = self.getLogger()
            self.frame = HomePage(self.driver)
            self.frame.home("Frames", 5)
            self.driver.find_element_by_xpath(
                '//a[text()="Nested Frames"]').click()
            self.topFrame = self.driver.find_element_by_xpath(
                '//frame[@name="frame-top"]')
            self.driver.switch_to.frame(self.topFrame)

            self.topLeft = self.driver.find_element_by_xpath(
                '//frame[@name="frame-left"]')
            self.driver.switch_to.frame(self.topLeft)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.log.info("Switched to main frame")
            self.driver.switch_to.frame(self.topFrame)
            self.topMiddle = self.driver.find_element_by_xpath(
                '//frame[@name="frame-middle"]')
            self.driver.switch_to.frame(self.topMiddle)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.log.info("Switched to main frame")
            self.driver.switch_to.frame(self.topFrame)
            self.topRight = self.driver.find_element_by_xpath(
                '//frame[@name="frame-right"]')
            self.driver.switch_to.frame(self.topRight)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.bottomFrame = self.driver.find_element_by_xpath(
                '//frame[@name="frame-bottom"]')
            self.driver.switch_to.frame(self.bottomFrame)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

        except:

            self.log.error(sys.exc_info())
            assert False
示例#15
0
 def test_frames(self):
     try:
         self.log = self.getLogger()
         self.frame = HomePage(self.driver)
         self.frame.home("Frames", 5)
         self.driver.find_element_by_xpath('//a[text()="iFrame"]').click()
         if "An iFrame containing the TinyMCE WYSIWYG Editor" in self.driver.find_element_by_xpath(
                 '//h3').text:
             self.log.info("Navigated to the correct page")
         else:
             self.log.error("Wrong Page")
         self.iframe = self.driver.find_element_by_xpath(
             '//iframe[@id="mce_0_ifr"]')
         self.driver.switch_to.frame(self.iframe)
         self.driver.find_element_by_xpath(
             '//*[@id="tinymce"]/p').send_keys(
                 "This is the changed frame.ss")
         self.driver.close()
     except:
         self.log.error(sys.exc_info())
         assert False
示例#16
0
    def test_exit_intent(self):
        try:
            self.log = self.getLogger()
            self.exit = HomePage(self.driver)
            self.exit.home("Exit Intent", 10)
            self.action = ActionChains(self.driver)
            self.log.info("Created action object")

            self.log.info("Created model object")
            self.log.info("CHeck done")
            self.action.move_by_offset(0, 0).perform()
            self.log.info("Mouse moved by offset")
            self.model = self.driver.find_element_by_xpath(
                '//div[@class="model-body"]')
            if self.model.is_displayed():
                self.log.info("The pop up is displayed")
            else:
                self.log.error("The Pop up is not displayed")
        except:
            self.log.error(sys.exc_info())
            assert False
示例#17
0
    def test_horizontal_slider(self):
        try:
            self.log = self.getLogger()
            self.slide = HomePage(self.driver)
            self.slide.home("Horizontal Slider", 10)
            self.driver.find_element_by_xpath('//input[@type="range"]').click()
            sleep(4)
            self.originalval = self.driver.find_element_by_xpath(
                '//span[@id="range"]').text
            self.driver.find_element_by_xpath(
                '//input[@type="range"]').send_keys(Keys.ARROW_RIGHT)
            self.changedval = self.driver.find_element_by_xpath(
                '//span[@id="range"]').text
            if float(self.changedval) == float(self.originalval) + 0.5:
                self.log.info("Working fine")
            else:
                self.log.warning("Not working")

        except:
            self.log.error(sys.exc_info())
            assert False
示例#18
0
class TestFrames(BaseClass):
    def test_frames(self):
        try:
            self.log = self.getLogger()
            self.frame = HomePage(self.driver)
            self.frame.home("Frames", 5)
            self.driver.find_element_by_xpath('//a[text()="iFrame"]').click()
            if "An iFrame containing the TinyMCE WYSIWYG Editor" in self.driver.find_element_by_xpath(
                    '//h3').text:
                self.log.info("Navigated to the correct page")
            else:
                self.log.error("Wrong Page")
            self.iframe = self.driver.find_element_by_xpath(
                '//iframe[@id="mce_0_ifr"]')
            self.driver.switch_to.frame(self.iframe)
            self.driver.find_element_by_xpath(
                '//*[@id="tinymce"]/p').send_keys(
                    "This is the changed frame.ss")
            self.driver.close()
        except:
            self.log.error(sys.exc_info())
            assert False

    def test_nestedframes(self):
        try:
            self.log = self.getLogger()
            self.frame = HomePage(self.driver)
            self.frame.home("Frames", 5)
            self.driver.find_element_by_xpath(
                '//a[text()="Nested Frames"]').click()
            self.topFrame = self.driver.find_element_by_xpath(
                '//frame[@name="frame-top"]')
            self.driver.switch_to.frame(self.topFrame)

            self.topLeft = self.driver.find_element_by_xpath(
                '//frame[@name="frame-left"]')
            self.driver.switch_to.frame(self.topLeft)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.log.info("Switched to main frame")
            self.driver.switch_to.frame(self.topFrame)
            self.topMiddle = self.driver.find_element_by_xpath(
                '//frame[@name="frame-middle"]')
            self.driver.switch_to.frame(self.topMiddle)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.log.info("Switched to main frame")
            self.driver.switch_to.frame(self.topFrame)
            self.topRight = self.driver.find_element_by_xpath(
                '//frame[@name="frame-right"]')
            self.driver.switch_to.frame(self.topRight)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

            self.driver.switch_to.default_content()
            self.bottomFrame = self.driver.find_element_by_xpath(
                '//frame[@name="frame-bottom"]')
            self.driver.switch_to.frame(self.bottomFrame)
            self.log.info(self.driver.find_element_by_xpath('//body').text)

        except:

            self.log.error(sys.exc_info())
            assert False