예제 #1
0
def oneTimeSetUp(request, browser):
    """
    One Time Setup method
    Calls WebDriverFactory class and gets a driver instance
    One time login for all test cases
    returns/yields driver instance to the respective calling class
    """

    print("Running one time setUp")
    wdf = WebDriverFactory(browser)
    driver = wdf.getWebDriverInstance()
    lp = LoginPage(driver)
    lp.clickLoginLink()
    lp.login("*****@*****.**", "abcabc")

    if request.cls is not None:
        request.cls.driver = driver
    yield driver
    driver.quit()
    print("Running one time tearDown")
예제 #2
0
def oneTimeSetUp(request, browser):
    print('One time setUp')

    # use WebDriverFactory class instance with argument (browser) from request
    wdf = WebDriverFactory(browser)
    driver = wdf.getWebDriverInstance()
    baseURL = 'https://letskodeit.teachable.com/'
    driver.get(baseURL)

    lp = LoginPage(driver)
    lp.login('*****@*****.**', 'abcabc')


    # add driver atribute to the test class using request keyword
    if request.cls is not None:
        request.cls.driver = driver

    yield driver
    driver.quit()
    print('One time tearDown')
예제 #3
0
def oneTimeSetup(request, command_line_browser, base_url) -> webdriver:
    """
    passing fixture name inside another fixture is possible, so that they get executed first
    we are calling another fixture 'command_line_browser' before executing oneTimeSetup to get the browsertype
    same goes for the base_url
    """
    print()
    print("*" * 60)
    print("Running conftest oneTimeSetup before every CLASS as specified")
    wdf = WebDriverFactory(command_line_browser, base_url)
    driver = wdf.getWebDriverFactoryInstance()
    if request.cls is not None:
        request.cls.driver = driver
        request.cls.baseUrl = base_url
    print("*" * 60)

    yield driver

    print("*" * 60)
    print("Running conftest oneTimeTearDown before every CLASS as specified")
    driver.quit()
    print("*" * 60)
예제 #4
0
def oneTimeSetUp(request, browser):
    print("Running one time setUp")
    wdf = WebDriverFactory(browser)
    driver = wdf.getWebDriverInstance()
    # if browser == 'chrome':
    #     baseURL = "https://courses.letskodeit.com/"
    #     driver = webdriver.Chrome()
    #     driver.maximize_window()
    #     driver.implicitly_wait(3)
    #     driver.get(baseURL)
    #     print("Running tests on GC")
    # else:
    #     baseURL = "https://courses.letskodeit.com/"
    #     driver = webdriver.Firefox()
    #     driver.get(baseURL)
    #     print("Running tests on chrome")

    if request.cls is not None:
        request.cls.driver = driver

    yield driver
    driver.quit()
    print("Running one time tearDown")
예제 #5
0
    def testingdatabase(self):

        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()
        """TestCase TC001;Click Run SQL button and see table """

        dtb = DatabaseVerification(driver)
        dtb.codemirrorline()
        dtb.runsqlbutton()
        element = "//button[@class='w3-green w3-btn']"

        if element.is_enabled():
            print("TestCase TC001 IS PASS")
        else:
            print("TestCase TC001 IS FAIL")
        """TestCase TC002; Get all table numbers"""

        dtb.texttablenumbers()
        expectnumber = "62"

        if expectnumber == dtb.texttablenumbers():
            print("TestCase TC002 IS PASS")
        else:
            print("TestCase TC002 IS FAIL")
예제 #6
0
    def TC007(self):

        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()

        htl = HotelPage(driver)
        htl.hoteltab()
        htl.selectcitygoingtotab("new york")
        htl.checkintab()
        htl.checkindate()
        htl.checkouttab()
        htl.checkoutdate()
        htl.adulttab()
        htl.addroom()
        htl.closeadulttab()
        htl.seachinghotels()

        ExpectedResult = "https://www.expedia.com/Hotel-Search?destination=New+York%2C+New+York&latLong=40.75668%2C-73.98647&regionId=178293&startDate=08%2F14%2F2019&endDate=08%2F15%2F2019&rooms=2&adults=2%2C1"
        ActualResult = driver.current_url

        if ExpectedResult == ActualResult:
            print("Test Case Tc007: Pass")
        else:
            print("Test Case Tc007: Fail")
예제 #7
0
class LoginTestsTJ:
    def __init__(self):
        self.wdf = WebDriverFactory(browser="")
        self.driver = self.wdf.getWebDriverInstance()
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)

    log = cl.customLogger(logging.DEBUG)

    @afterTest()
    def afterTest(self):
        self.driver.quit()

    @test()
    def test_t1invalidLogin(self):
        """
        Tests for invalid login test case
        Logs out first because of oneTimeSetup Login
        """
        self.log.info("*#" * 20)
        self.log.info("test_t1invalidLogin started")
        self.log.info("*#" * 20)
        self.lp.logout()
        self.lp.clickLoginLink()
        self.lp.login("*****@*****.**", "abcabcabc")
        result = self.lp.verifyLoginFailed()
        assert result == True

    @test()
    def test_t2validLogin(self):
        """
        Tests for valid login test case
        Also tests for Login Title
        Uses TestStatus class to mark/assert test case results
        """
        self.log.info("*#" * 20)
        self.log.info("test_t2validLogin started")
        self.log.info("*#" * 20)
        self.lp.login("*****@*****.**", "abcabc")
        result1 = self.lp.verifyLoginTitle()
        self.ts.mark(result1, "Title Verification")
        result2 = self.lp.verifyLoginSuccessful()
        print("Result1: " + str(result1))
        print("Result2: " + str(result2))
        self.ts.markFinal("test_t2validLogin", result2, "Login Verification")
예제 #8
0
    def TC005(self):
        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()

        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()
        htl = HotelPage(driver)
        htl.hoteltab()
        htl.checkouttab()
        htl.checkoutdate()
        htl.adulttab()
        htl.adultadd()
        htl.closeadulttab()
        element = driver.find_element_by_xpath(
            "//*[@id='traveler-selector-hp-hotel']/div/ul/li/button")
        if element.is_enabled():
            print("Test Case Tc005: Pass")
        else:
            print("Test case Tc005: Fail")
예제 #9
0
    def test_flight(self):
        global driver
        wd = WebDriverFactory(browser="chrome.driver")
        driver = wd.getWebDriverInstance()

        fp = FlightPage(driver)
        fp.flights3(" Bos")

        expectedUrl = "https://www.expedia.com/"
        currentUrl = driver.current_url
        print(currentUrl)

        if currentUrl == expectedUrl:
            print("TC007_Checking The Url Pass")
        else:
            print("TC007 Checking The Url Fail")

        print("*" * 20)

        if driver.find_element_by_xpath(
                "//label[@id='flight-type-roundtrip-label-hp-flight']"
        ).is_enabled():
            print("TC009_Clicking Round Trip Button Pass")
        else:
            print("TC009_Clicking round Trip Button Fail")

        print("*" * 20)

        dept_area = (driver.find_element_by_xpath(
            "//section[@id='section-flight-tab-hp']//div[contains(@class,'cols-nested ab25184-location')]//div[1]//div[1]//div[2] "
        ))

        if dept_area.is_enabled():
            print("TC010_Selecting Depart Area Pass")
        else:
            print("TC010_Selecting Depart Area Fail")

        print("*" * 20)

        message = driver.find_element_by_xpath(
            "//h5[@class='alert-title no-outline']")
        print(message.text)

        if message.text == "Please correct the errors below.":
            print("TC016_All Mandatory Fields Should Be Fill Out Pass")
        else:
            print("TC016_All Mandatory Fields Should Be Fill Out Fail")

        print("*" * 20)

        dept_date = driver.find_element_by_xpath(
            " //input[@id='flight-departing-hp-flight']")
        print(dept_date.text)

        if dept_date.text == "08/24/2019":
            print("TC012_Checking Depart Date Pass")
        else:
            print("TC012_Checking Depart Date Fail")

        print("*" * 20)

        arriv_date = driver.find_element_by_xpath(
            "//input[@id='flight-returning-hp-flight']")
        print(arriv_date.text)

        if dept_date.text == "08/24/2019":
            print("TC013_Checking Return Date Pass")
        else:
            print("TC013_Checking Return Date Fail")

        fp = FlightPage(driver)
        fp.flights1(" New York")

        arrival_area = driver.find_element_by_xpath(
            "//section[@id='section-flight-tab-hp']//div[contains(@class,'cols-nested ab25184-location')]//div[1]//div[1]//div[2] "
        )
        if arrival_area.is_enabled():
            print("TC011_Selecting The Arrival Area Pass")
        else:
            print("TC011_Selecting The Arrival Area Fail")

        print("*" * 20)

        fp = FlightPage(driver)
        fp.flights2()

        if len(
                driver.find_elements_by_xpath(
                    "//div[@data-test-id='listing-main']")) == 0:
            print("TC014_Checking The List Of Flights Fail")
        else:
            print("TC014_Checking The List Of Flights Pass")

        print("*" * 20)

        if (driver.find_element_by_xpath(
                "//span[@class='secondary-playback-summary']")).is_displayed():
            print("TC017_Checking The Selections Present Pass")
        else:
            print("TC017_Checking The Selections Present Fail")

        print("*" * 20)

        if (driver.find_element_by_xpath("//input[@id='stopFilter_stops-0']")
            ).is_selected():
            print("TC019_Selecting Nonstop Button Pass")
        else:
            print("TC019_Selecting Nonstop Button Fail")

        print("*" * 20)

        if ((driver.find_element_by_xpath(
                " //input[@id='airlineRowContainer_AA']"))
                and (driver.find_element_by_xpath(
                    "//input[@id='airlineRowContainer_DL']"))).is_selected():
            print("TC020_Selecting Airlines Brand Pass")
        else:
            print("TC020_Selecting Airlines Brand Fail")

        print("*" * 20)

        if (driver.find_element_by_xpath(
                "//input[@id='leg0-morning-departure']")).is_selected():
            print("TC021_Selecting The Departure Time Pass")
        else:
            print("TC021_Selecting The Departure Time Fail")

        print("*" * 20)

        if (driver.find_element_by_xpath("//input[@id='leg0-morning-arrival']")
            ).is_selected():
            print("TC022_Selecting Arrival Time Pass")
        else:
            print("TC022_Selecting Arrival Time Fail")

        print("*" * 20)
예제 #10
0
def getDriver():
    wdf = WebDriverFactory()
    driver = wdf.getWebDriverInstance()
    return driver
예제 #11
0
    def test_page_1(self):
        """Click Hotels Reservations Button"""

        wd=WebDriverFactory(browser="firefox")
        driver=wd.getWebDriverInstance()

        htl = HotelPage(driver)
        htl.hoteltab()

        element=driver.find_element_by_xpath("//button[@id='tab-hotel-tab-hp']")
        if element.is_enabled():
            print("Test Case Tc001: Pass")
        else:
            print("Test case Tc001: Fail")


        """Enter City Name to Going to Tab"""

        htl.selectcitygoingtotab("new york")

        element = driver.find_element_by_xpath("//input[@id='hotel-destination-hp-hotel']")
        if element.is_enabled():
            print("Test Case Tc002: Pass")
        else:
            print("Test case Tc002: Fail")


        """Select Checkin Date"""

        htl.checkintab()
        htl.checkindate()

        element = driver.find_element_by_xpath("//input[@id='hotel-checkin-hp-hotel']")
        if element.is_enabled():
            print("Test Case Tc003: Pass")
        else:
            print("Test case Tc003: Fail")


        """Select Checkout Date"""

        htl.checkouttab()
        htl.checkoutdate()

        element = driver.find_element_by_xpath("//input[@id='hotel-checkout-hp-hotel']")
        if element.is_enabled():
            print("Test Case Tc004: Pass")
        else:
            print("Test case Tc004: Fail")


        """Click Travelers Part and close travelers tab"""

        htl.adulttab()

        element = driver.find_element_by_xpath("//*[@id='traveler-selector-hp-hotel']/div/ul/li/button")
        if element.is_enabled():
            print("Test Case Tc005: Pass")
        else:
            print("Test case Tc005: Fail")


        """Click Travelers and add Adult part"""

        htl.adultadd()


        element = driver.find_element_by_xpath("//*[@id='traveler-selector-hp-hotel']/div/ul/li/button")
        if element.is_enabled():
            print("Test Case Tc006: Pass")
        else:
            print("Test case Tc006: Fail")


        """Click Travelers and click Room part"""

        htl.addroom()


        element = driver.find_element_by_xpath("//*[@id='traveler-selector-hp-hotel']/div/ul/li/button")
        if element.is_enabled():
            print("Test Case Tc007: Pass")
        else:
            print("Test case Tc007: Fail")


        """Click Travelers and click child travelers part"""


        # htl.childadd()
        htl.closeadulttab()

        element = driver.find_element_by_xpath("//*[@id='traveler-selector-hp-hotel']/div/ul/li/button")
        if element.is_enabled():
            print("Test Case Tc008: Pass")
        else:
            print("Test case Tc008: Fail")


        """Click search  and go to next hotels results page"""


        htl.seachinghotels()


        if driver.find_element_by_xpath("//legend[contains(text(),'Sort by')]").is_displayed():
            print("Test Case Tc009: Pass")
        else:
            print("Test Case Tc009: Fail")


        """Select Sort by Price and list hotels"""


        htl.sortbyprice()

        element = driver.find_element_by_xpath("//input[@id='radio-sort-price']")
        if element.is_enabled():
            print("Test Case Tc010: Pass")
        else:
            print("Test case Tc010: Fail")
예제 #12
0
    def test_page_1(self):
        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()
        ft = FlightPage(driver)
        """ Click and verify flight tab  """
        ft.flight()

        element = driver.find_element_by_id("tab-flight-tab-hp")
        if element.is_enabled():
            print("Test case TC001: Pass")
        else:
            print("Test case TC001: Fail")
        """ Click and verify roundtrip tab  """
        ft.rounttrip()

        element = driver.find_element_by_xpath(
            "//label[@id='flight-type-roundtrip-label-hp-flight']")
        if element.is_displayed():
            print("Test Case Tc002: Pass")
        else:
            print("Test case Tc002: Fail")
        """ Click and verify destination city tab  """
        ft.destinationcity("boston")

        if driver.find_element_by_xpath(
                "//*[@id='flight-origin-hp-flight']").is_enabled():
            print("Test Case TC003: Pass")
        else:
            print("Test case TC003: Fail")
        """ Select destination city and verify """
        element = driver.find_element_by_xpath(
            "//a[@id='aria-option-1']//span[2]")

        if driver.find_element_by_xpath(
                "//a[@id='aria-option-1']//span[2]").is_enabled():
            ft.destinationselect()
            print("Test Case TC004: Pass")
        else:
            print("Test case TC004: Fail")
        """ Click and verify arrive city tab  """
        ft.arrivecity("new york")

        if driver.find_element_by_xpath(
                "//*[@id='flight-destination-hp-flight']").is_enabled():
            print("Test Case TC005: Pass")
        else:
            print("Test case TC005: Fail")
        """ Select arrive city and verify  """
        element = driver.find_element_by_xpath(
            "//*[@id='aria-option-0']/span[2]/div")
        if element.is_enabled():
            ft.arriveselect()
            print("Test Case TC006: Pass")
        else:
            print("Test case TC006: Fail")
        """ Click and verify departure calender tab  """
        ft.calenderdeparture()

        element = driver.find_element_by_id("flight-departing-hp-flight")
        if element.is_enabled():
            print("Test Case TC007: Pass")
        else:
            print("Test case TC007: Fail")
        """ Select and verify departure date  """
        element = driver.find_element_by_xpath(
            "//button[@data-day='25' and @data-month='8']")

        if element.is_enabled():
            ft.datedeparture()
            print("Test Case TC008: Pass")
        else:
            print("Test case TC008: Fail")
        """ Click and verify arrive calender tab  """
        ft.calenderarrive()

        if driver.find_element_by_id(
                "flight-returning-hp-flight").is_enabled():
            print("Test Case TC009: Pass")
        else:
            print("Test case TC009: Fail")
        """ Select and verify arrive date """
        element = driver.find_element_by_xpath(
            "//button[@data-day='28' and @data-month='8']")
        if element.is_displayed():
            ft.datearrive()
            print("Test Case TC010: Pass")
        else:
            print("Test case TC010: Fail")
        """ Click and verify travelers tab  """
        ft.travelers()

        element = driver.find_element_by_xpath(
            "//div[@id='traveler-selector-hp-flight']//div/ul/li/button")
        if element.is_enabled():
            print("Test Case TC011: Pass")
        else:
            print("Test case TC011: Fail")
        """ Select and verify travelers number """
        ft.travelers_plus()

        element = driver.find_element_by_xpath(
            "//*[@id='traveler-selector-hp-flight']/div/ul/li/div/div/div/div[1]/div[4]/button/span[1]"
        )

        if element.is_enabled():
            print("Test Case TC012: Pass")
        else:
            print("Test case TC012: Fail")
        """ Close and verify travelers tab  """
        element = driver.find_element_by_xpath(
            "//*[@id='traveler-selector-hp-flight']/div/ul/li/div/footer/div/div[2]/button"
        )

        if element.is_enabled():
            ft.close_tab()
            print("Test Case TC013: Pass")
        else:
            print("Test case TC013: Fail")
        """ Select and verify search tab  """
        element = driver.find_element_by_css_selector(
            "#gcw-flights-form-hp-flight > div.cols-nested.ab25184-submit > label > button"
        )
        if element.is_enabled():
            print("Test Case TC014: Pass")
            ft.search()
        else:
            print("Test case TC014: Fail")
        """ Filter and verify nonstop flight  """
        ft.nonstop()

        if (driver.find_element_by_xpath("//input[@id='stopFilter_stops-0']")
            ).is_displayed():
            print("Test Case TC015: Pass")
        else:
            print("Test case TC015: Fail")
예제 #13
0
    def test_page3(self):
        wd = WebDriverFactory(browser="firefox")
        driver = wd.get3WebDriverInstance()
        ft = FlightPage(driver)
        """ Click and verify booking tab  """
        ft.booking()

        location_info = driver.find_element_by_xpath(
            "//div[@class='location-info']").text
        if location_info == "Boston (BOS) to New York (JFK)":
            print("Test Case TC019: Pass")
        else:
            print("Test case TC019: Fail")
        """ Select and verify first traveler information part """
        ft.firsttr_name("AZIME")
        ft.firsttr_lastname("SUKUSU")
        ft.phonenumber("8572728900")
        ft.firsttr_gender()
        # ft.firsttr_mob()
        # ft.firsttr_mob1()
        # ft.firsttr_dob()
        # ft.firsttr_dob1()
        # ft.firsttr_yob()
        # ft.firsttr_yob1()

        if (driver.find_element_by_xpath("//input[@id='firstname[0]']")
            ).is_displayed():
            print("Test Case TC020: Pass")
        else:
            print("Test case TC020: Fail")
        """ Select and verify select traveler information part """
        ft.secondtr_name("MERT")
        ft.secondtr_lastname("SUKUSU")
        ft.secondtr_gender()
        # ft.secondtr_mob()
        # ft.secondtr_mob1()
        # ft.secondtr_dob()
        # ft.secondtr_dob1()
        # ft.secondtr_yob()
        # ft.secondtr_yob1()

        if (driver.find_element_by_xpath("//input[@id='firstname[1]']")
            ).is_displayed():
            print("Test Case TC021: Pass")
        else:
            print("Test case TC021: Fail")
        """ Select and verify payment part """
        ft.noinsurance()
        ft.name_oncard("AZIME SUKUSU")
        ft.card_number("5253123456723456")
        ft.expiration_month()
        ft.expiration_month1()
        ft.expiration_year()
        ft.expiration_year1()
        # ft.security_code("253")

        if (driver.find_element_by_xpath(
                "//select[@name='creditCards[0].expiration_year']")
            ).is_enabled():
            print("Test Case TC022: Pass")
        else:
            print("Test case TC022: Fail")
        """ Select and verify billing address part """
        ft.billing_address1("375 ACORN PARK DR")
        ft.billing_address2("APT 4301")
        ft.billingcity("BELMONT")
        ft.billing_state()
        ft.billing_state1()
        ft.billing_zipcode("02478")
        ft.conf_email("*****@*****.**")
        ft.create_password("12345abcde")
        ft.confirm_password("12345abcde")

        if (driver.find_element_by_xpath("//input[@name='repeat_password']")
            ).is_enabled():
            print("Test Case TC023: Pass")
        else:
            print("Test case TC023: Fail")
        """ Click and verify complete booking button """

        if (driver.find_element_by_xpath("//button[@id='complete-booking']")
            ).is_enabled():
            # ft.complete_booking()
            print("Test Case TC024: Pass")
        else:
            print("Test case TC024: Fail")
예제 #14
0
    def run_All_testCase(self, testCaseJson, baseURL):

        wdf = WebDriverFactory(self.driver)
        if baseURL == '':
            self.log.error("Base URL not Inserted")
        self.driver = wdf.getWebDriverInstance(baseURL=baseURL)
        self.stat = Status(self.driver)
        self.util = Util()

        for test in testCaseJson:
            self.element = test['FindElement']
            self.Action = test['ActionCommand']
            self.elementType = test['FindElementType']
            self.Data = test['ActionParameters']
            self.waitAfterCmd = int(float(test['WaitAfterCommand']))
            self.timeOut = int(float(test['Wait-Timeout']))

            if self.Action == "login":
                email = self.Data.strip().split(",")[0]
                password = self.Data.strip().split(",")[1]
                email_locator = self.element.strip().split(",")[0]
                password_locator = self.element.strip().split(",")[1]
                self.sendKeys(email, email_locator, self.elementType)
                time.sleep(self.waitAfterCmd)
                self.sendKeys(password, password_locator, self.elementType)
                self.waitForElement(self.element, self.elementType,
                                    self.timeOut)

            elif self.Action == "isElementPresent":
                result = self.isElementPresent(self.element, self.elementType)
                self.stat.markFinal("Test" + self.element, result, "")
                self.reports.update({test['ActionNo']: result})

            elif self.Action == "elementClick":
                self.elementClick(self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "verifyTextContains":
                exceptedText = self.getText(self.element, self.elementType)
                result = self.util.verifyTextContains(self.Data, exceptedText)
                self.stat.markFinal("Test" + self.element, result,
                                    "Text Contains")
                self.reports.update({test['ActionNo']: result})

            elif self.Action == "sendKeys":
                self.sendKeys(self.Data, self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "waitForElement":
                self.waitForElement(self.element, self.elementType,
                                    self.timeOut)

            elif self.Action == "isElementPresent":
                result = self.isElementPresent(self.element, self.elementType)
                self.stat.markFinal("Test" + self.element, result, "")
                self.reports.update({test['ActionNo']: result})

            elif self.Action == "clearField":
                self.clearField(self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "getTitle":
                result = self.getTitle()
                print(result)

            elif self.Action == "isElementDisplayed":
                self.isElementDisplayed(self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "scrollIntoView":
                self.scrollIntoView(self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "mouseHover":
                self.mouseHover(self.element, self.elementType)
                self.waitForElement(self.element, self.elementType,
                                    self.timeOut)

            elif self.Action == "mouseClick":
                self.mouseClick(self.element, self.elementType)
                time.sleep(self.waitAfterCmd)

            elif self.Action == "webScroll":
                self.webScroll(self.Data)
                time.sleep(self.waitAfterCmd)

        self.driver.quit()
예제 #15
0
 def __init__(self):
     self.wdf = WebDriverFactory(browser="")
     self.driver = self.wdf.getWebDriverInstance()
     self.lp = LoginPage(self.driver)
     self.ts = TestStatus(self.driver)
        self.actionOnElement()
        self.searchSetting()
        self.getSleep(1)
        self.saveSetting()

    def veryfyAlertTextMatchAndAccept(self, expected):
        alert = self.getAlert()
        if alert:
            actualAlertText = alert.text
            result = self.util.isTextMatch(actualAlertText, expected)
            if result:
                alert.accept()
                msg = '点选弹窗“确认”选项'
                print(msg)
            return result
        return alert


if __name__ == '__main__':
    try:
        from base.webdriverfactory import WebDriverFactory
        wdf = WebDriverFactory('chrome')
        driver = wdf.getBrowserInstance('https://www.baidu.com')
        bs = BaiduSetting(driver)
        bs.performBaiduSetting()
        result = bs.veryfyAlertTextMatchAndAccept('已经记录下您的使用偏好')
        msg = ('实际弹窗信息与提供的弹窗信息是否相符:{}'.format(result))
        print(msg)
    finally:
        bs.getClose()
예제 #17
0
    def testingcourse(self):
        """TestCase TC001; Go to Let Kode it and login"""
        wd = WebDriverFactory(browser="firefox")
        driver = wd.getWebDriverInstance()

        ## Go to Login Page and Sign In Lets Kode it
        sc = SelectCourse(driver)
        sc.login("*****@*****.**", "abcabc")

        currentpage = driver.current_url
        expectedpage = "https://learn.letskodeit.com/"

        if currentpage == expectedpage:
            print("TestCase TC001: Pass")
        else:
            print("TestCase TC001: Fail")
        """TestCase TC002; Click All Course Button"""

        ## Click All course button then go to all course page
        sc.allcourse()

        currentresult = driver.current_url
        expectedresult = "https://learn.letskodeit.com/courses"
        if currentresult == expectedresult:
            print("TestCase TC002: Pass")
        else:
            print("TestCase TC002: Fail")
        """TestCase TC003; Click Search button and write Python """
        ##Write Python to search button
        sc.searchbutton("python")

        element = driver.find_element_by_xpath("//input[@id='search-courses']")
        if element.is_enabled():
            print("TestCase TC003: Pass")
        else:
            print("TestCase Tc003: Fail")
        """TestCase TC004; Click Category Button and select Software Testing """

        sc.categoryall()
        sc.softwaretesting()

        currentresult = driver.current_url
        expectedresult = "https://learn.letskodeit.com/courses/category/Software%20Testing"
        if currentresult == expectedresult:
            print("TestCase TC004: Pass")
        else:
            print("TestCase TC004: Fail")
        """TestCase Tc005; Click Author Button and select Let's kode it button """

        sc.author_all()
        sc.letskodeitbutton()

        element = driver.find_element_by_xpath(
            "//div[contains(text(),'Author:')]")
        if element.is_enabled():
            print("TestCase TC005: Pass")
        else:
            print("TestCase TC005: Fail")
        """TestCase Tc006; Click Selenium WebDriver With Python 3 Course and go to next page"""

        ##Click Selenium Webdriver with Python Course button
        sc.seleniumpythoncourse()

        ##Check expected result
        currentresult = driver.current_url
        expectedresult = "https://learn.letskodeit.com/p/selenium-webdriver-with-python3"

        if currentresult == expectedresult:
            print("TestCase TC006: Pass")
        else:
            print("TestCase TC006: Fail")
        """TestCase Tc007; Click Watch Promo Video"""

        sc.watchpromo()

        element = driver.find_element_by_xpath("//button[@class='close']")
        if element.is_enabled():
            print("TestCase TC007: Pass")
        else:
            print("TestCase TC007: Fail")
        """TestCase Tc008; Close Promo video """
        ##Close promo video
        sc.closepromovideo()

        element = driver.find_element_by_xpath("//a[@id='watchpromo']")

        if element.is_enabled():
            print("TestCase TC008: Pass")
        else:
            print("TestCase TC008: Fail")
        """TestCase Tc009; Click Enroll course button and go to payment page"""

        ## Click Enroll in Course Button
        sc.enrollcourse()

        ##Check expected result
        currentresult = driver.current_url
        expectedresult = "https://sso.teachable.com/secure/42299/checkout/342638/selenium-webdriver-with-python3"

        if currentresult == expectedresult:
            print("TestCase TC009: Pass")
        else:
            print("TestCase TC009: Fail")
예제 #18
0
def one_time_setup(request, browser, base_url):
    wdf = WebDriverFactory(browser, base_url)
    driver = wdf.get_webdriver()
    yield driver, base_url
    driver.quit()
예제 #19
0
class GUIBaseTestCase(unittest.TestCase):

    wdf = WebDriverFactory()
    remoteSession = wdf.cfg.getConfiguration('Grid', 'remote')
    driver = None
    startTime = int(round(time.time() * 1000))
    testStartTime = int(round(time.time() * 1000))
    log = cl.customLogger()
    util = Util()
    checkPoint = CheckPoint()

    # def __init__(self):
    #     """
    #     Inits GUIBaseTestCase class
    #
    #     Required Parameters:
    #         None
    #
    #     Optional Parameters:
    #         None
    #
    #     Returns:
    #         None
    #     """
    #     self.util = Util()
    #
    #     # Initialize common page objects
    #     # self.initializePages()
    #     self.checkPoint = CheckPoint()

    @classmethod
    def setUpClass(cls):
        """
        SetUp to initialize webdriver session, pages and other needed objects

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        #super().setUp()

        # wdf = WebDriverFactory()
        # remoteSession = wdf.cfg.getConfiguration('Grid', 'remote')
        # Get webdriver instance
        cls.driver = cls.wdf.getWebDriverInstance(remote=cls.remoteSession)
        cls.startTime = int(round(time.time() * 1000))

    def refresh(self):
        """
        Refresh current page on the web application

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        self.driver.refresh()
        self.log.info("The current browser location was refreshed")

    def initializePages(self):
        """
        Initialize pages

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        pass

    def setUp(self):
        """
        This method executes before every method in the test class

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        self.testStartTime = int(round(time.time() * 1000))
        self.checkPoint.clearStatus()
        self.log.info("***" * 30)
        self.log.info("Test Started --> :: " + self._testMethodName)
        self.log.info("***" * 30)

    def tearDown(self, refresh=True):
        """
        This method executes after every method in the test class

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        self.log.info("***" * 30)
        self.log.info("Test Ended --> :: " + self._testMethodName)
        testEndTime = int(round(time.time() * 1000))
        testDuration = (testEndTime - self.testStartTime) / 1000.00
        self.log.info("Time taken to execute test method :: " +
                      "{0:.2f}".format(testDuration) + " :: seconds")
        self.log.info("***" * 30)
        # self.checkPoint.clearStatus()
        if refresh:
            self.refresh()
            self.log.info("Page reload after the test case")

    @classmethod
    def tearDownClass(self):
        """
        TearDown to clean up anything that is need to cleaned up after the test class

        Required Parameters:
            None

        Optional Parameters:
            None

        Returns:
            None
        """
        endTime = int(round(time.time() * 1000))
        duration = (endTime - self.startTime) / 1000.00
        timeUnit = "seconds"
        if duration > 60.00:
            duration = duration / 60.0
            timeUnit = "minutes"
        # close the browser window
        self.driver.quit()
        self.log.info("Driver quit, session closed")
        self.log.info("***" * 30)
        self.log.info("Total Time taken to execute test suite :: " +
                      "{0:.2f}".format(duration) + " :: " + timeUnit)
        self.log.info("***" * 30)