Ejemplo n.º 1
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        nameTB = hw.getElement("name")
        nameTB.send_keys("Saul")
        alertBtn = hw.getElement("alertbtn")
        alertBtn.click()
        time.sleep(2)
        alert1 = driver.switch_to.alert
        alert1.accept()
        time.sleep(2)
        confirmBtn = hw.getElement("confirmbtn")
        nameTB.send_keys("Saul")
        confirmBtn.click()
        time.sleep(2)
        alert2 = driver.switch_to.alert
        alert2.dismiss()
        # Idle and Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 2
0
    def testMethod(self):
        #opt = webdriver.ChromeOptions()
        #opt.add_argument("user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
        baseUrl = "https://jqueryui.com/slider/"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()#options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        driver.switch_to.frame(0)
        time.sleep(2)
        Slider = hw.getElement("//div[@id='slider']//span","xpath")


        try:
            actions = ActionChains(driver)
            actions.drag_and_drop_by_offset(Slider,100,0).perform()
            print("Sliding element successful")
            time.sleep(2)

            print("Item clicked")
        except:
            print("Sliding failed on element")

        # Idle and Close
        time.sleep(5)
        driver.quit()
    def testMethod(self):
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        #Scroll down
        driver.execute_script("window.scrollBy(0,1000);")
        time.sleep(2)
        #Scroll up
        driver.execute_script("window.scrollBy(0,-1000)")
        time.sleep(5)
        #Scroll element into view
        element = hw.getElement("mousehover")
        driver.execute_script("arguments[0].scrollIntoView(true);",element)
        time.sleep(3)
        driver.execute_script("window.scrollBy(0,-350);")
        time.sleep(3)
        #Native way to scroll element into view
        driver.execute_script("window.scrollBy(0,-1000);")
        location = element.location_once_scrolled_into_view
        print("Location:" + str(location))

        #Idle and Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 4
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)
        #Login
        login_link = hw.getElement(
            "//div[@class='collapse navbar-collapse navbar-header-collapse']//a[contains(text(),'Login')]",
            "XPATH")
        login_link.click()
        username = hw.getElement("user_email")
        username.send_keys("*****@*****.**")
        user_password = hw.getElement("user_password")
        user_password.send_keys("abc")
        Loginbtn = hw.getElement("commit", "name")
        Loginbtn.click()
        destinationFilename = "C:\\Users\\Arkus\\Documents\\workspace_python\\AutomationTutorial\\test.png"
        try:
            driver.save_screenshot(destinationFilename)
            print("Screenshot saved: " + destinationFilename)

        except NotADirectoryError:
            print("Directory issue")
Ejemplo n.º 5
0
 def testMethod(self):
     opt = webdriver.ChromeOptions()
     opt.add_argument(
         "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
     )
     baseUrl = "https://letskodeit.teachable.com/"
     # Instantiate the FF browser command
     driver = webdriver.Chrome(options=opt)
     # Window maximize
     driver.maximize_window()
     # Open the provided URL
     driver.get(baseUrl)
     driver.implicitly_wait(5)
     hw = handyWrappers(driver)
     #Login
     login_link = hw.getElement(
         "//div[@class='collapse navbar-collapse navbar-header-collapse']//a[contains(text(),'Login')]",
         "XPATH")
     login_link.click()
     username = hw.getElement("user_email")
     username.send_keys("*****@*****.**")
     user_password = hw.getElement("user_password")
     user_password.send_keys("abc")
     Loginbtn = hw.getElement("commit", "name")
     Loginbtn.click()
     hw.takeScreenshot(driver)
    def testMethod(self):
        baseUrl = "https://www.expedia.mx/"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        flightsTab = hw.getElement(
            "//div[contains(@class,'StorefrontWizardRegionBEX')]//li[2]//a[1]",
            "xpath")
        flightsTab.click()

        datePicker1 = hw.getElement("//button[@id='d1-btn']", "xpath")
        datePicker1.click()

        departureDate = hw.getElement("//tr[5]//td[6]//button[1]", "xpath")
        departureDate.click()

        Listobtn = hw.getElement("//span[contains(text(),'Listo')]", "xpath")
        Listobtn.click()

        # Browser Close
        time.sleep(5)
        driver.quit()
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        #Handy Wrappers Object Creation
        hw = handyWrappers(driver)

        #Login ->
        time.sleep(2)
        LoginPresence = hw.isElementPresent("Login", By.LINK_TEXT)
        if LoginPresence:
            Loginlink = hw.getElement("Login", "LINKTEXT")
            Loginlink.click()
            email = hw.getElement("user_email")
            password = hw.getElement("user_password")
            email.send_keys("*****@*****.**")
            password.send_keys("abcabc")
            loginbtn = hw.getElement("commit", "name")
            loginbtn.click()
            #return True

        # Search for courses
        time.sleep(2)
        AllCourses = hw.getElement("All Courses", "LINKTEXT")
        AllCourses.click()
        time.sleep(2)
        searchBox = hw.getElement("search-courses")

        # Select course
        _course = "//div[contains(@class,'course-listing-title') and contains(text(),'{0}')]"
        course_name = input("Please enter the name of the course: ")
        _course_locator = _course.format(str(course_name))
        searchBox.send_keys(course_name)
        course_box = hw.getElement(_course_locator, "xpath")
        course_box.click()

        # Browser Close
        time.sleep(10)
Ejemplo n.º 8
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        #Find parent handle -> Main Window
        parentHandle = driver.current_window_handle
        print("Parent handle: " + parentHandle)
        #Find open window and click it
        element = hw.getElement("openwindow")
        element.click()
        time.sleep(2)
        #Find all handles, there should be two handles after clicking open window button
        allHandles = driver.window_handles
        for handle in allHandles:
            print("Handle: " + handle)
            if handle not in parentHandle:
                # Switch to window and search course
                driver.switch_to.window(handle)
                print("Switched to window: " + handle)
                searchBox = hw.getElement("search-courses")
                searchBox.send_keys("python")
                time.sleep(3)
                driver.close()
                break

        #Switch back to the parent handle
        driver.switch_to.window(parentHandle)
        element2 = hw.getElement("name")
        element2.send_keys("Loop")

        #Idle and Close
        time.sleep(5)
        driver.quit()
    def testMethod(self):
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        textField = hw.getElement("name")
        textField.send_keys("Test")
        time.sleep(2)
        textField2 = hw.getElement("//input[@id='name']", "xpath")
        textField2.clear()
        # Browser Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 10
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument("user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        height = driver.execute_script("return window.innerHeight;")
        width = driver.execute_script("return window.innerWidth;")

        print("Height: " + str(height))
        print("Width: " + str(width))

        #Idle and Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 11
0
    def testMethod(self):
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        #Handy Wrappers Object Creation
        hw = handyWrappers(driver)

        elementresult = hw.isElementPresent("name", By.ID)
        print(str(elementresult))

        elementresult2 = hw.elementPresenceCheck("//input[@id='name']",
                                                 By.XPATH)
        print(str(elementresult2))

        # Browser Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 12
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        driver.execute_script("window.scrollBy(0,600);")
        time.sleep(2)
        mouseHoverbtn = hw.getElement("mousehover")
        Topbtn = hw.getElement(
            ".//div[@class='mouse-hover-content']//a[text()='Top']", "xpath")
        Refreshbtn = hw.getElement(
            ".//div[@class='mouse-hover-content']//a[text()='Reload']",
            "xpath")

        try:
            actions = ActionChains(driver)
            actions.move_to_element(mouseHoverbtn).perform()
            print("Mouse Hovered on element")
            time.sleep(2)
            actions.move_to_element(Topbtn).click().perform()
            print("Item clicked")
        except:
            print("Mouse Hover failed on element")

        # Idle and Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 13
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)
        driver.execute_script("window.scrollBy(0,1800);")

        #Switch to frame using Id
        #driver.switch_to.frame("courses-iframe")
        #time.sleep(3)
        #Switch to frame using name
        #driver.switch_to.frame("iframe-name")
        #time.sleep(3)
        #Switch to frame using numbers
        driver.switch_to.frame(0)
        time.sleep(3)
        #Search courses
        searchBox = hw.getElement("search-courses")
        searchBox.send_keys("python")
        time.sleep(2)
        #Switch back to parent handle
        driver.switch_to.default_content()
        driver.execute_script("window.scrollBy(0,-1800);")
        element = hw.getElement("name")
        element.send_keys("Tester")
        # Idle and Close
        time.sleep(5)
        driver.quit()
Ejemplo n.º 14
0
    def testMethod(self):
        opt = webdriver.ChromeOptions()
        opt.add_argument(
            "user-data-dir=C:\\Users\\Arkus\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
        )
        baseUrl = "https://letskodeit.teachable.com/p/practice"
        # Instantiate the FF browser command
        driver = webdriver.Chrome(options=opt)
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        #driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)
        driver.execute_script(
            "window.location = 'https://letskodeit.teachable.com/p/practice';")

        element = driver.execute_script(
            "return document.getElementById('name');")
        element.send_keys("Tester")

        #Idle and Close
        time.sleep(10)
        driver.quit()
    def testMethod2(self):
        baseUrl = "https://www.expedia.mx/"
        # Instantiate the FF browser command
        driver = webdriver.Chrome()
        # Window maximize
        driver.maximize_window()
        # Open the provided URL
        driver.get(baseUrl)
        driver.implicitly_wait(5)
        hw = handyWrappers(driver)

        flightsTab = hw.getElement(
            "//div[contains(@class,'StorefrontWizardRegionBEX')]//li[2]//a[1]",
            "xpath")
        flightsTab.click()

        departureBox = hw.getElement(
            "//div[@id='location-field-leg1-origin-menu']//button[@class='uitk-faux-input']",
            "xpath")
        departureBox.send_keys("Tijuana")

        DepartureList = driver.find_element_by_xpath(
            "//ul[@class='uitk-typeahead-results no-bullet']")
        Departures = DepartureList.find_elements(By.TAG_NAME, "strong")
        for dest in Departures:
            print(dest.text)
            if dest.text == "Tijuana (TIJ - A. Internacional General Abelardo L. Rodríguez)":
                dest.click()
                break
        destinationBox = hw.getElement(
            "//div[@id='location-field-leg1-destination-menu']//button[@class='uitk-faux-input']",
            "xpath")
        destinationBox.send_keys("Japon")

        DepartureList = driver.find_element_by_xpath(
            "//div[@class='uitk-menu-container elevation-8 uitk-menu-open uitk-menu-pos-left']"
        )
        Departures = DepartureList.find_elements(By.TAG_NAME, "strong")
        for dest in Departures:
            if dest.text == "Tokio (NRT - A. Internacional de Narita)":
                dest.click()
                break

        datePicker1 = hw.getElement("//button[@id='d1-btn']", "xpath")
        datePicker1.click()
        calMonth = driver.find_element_by_xpath(
            "//div[@class='uitk-new-date-picker-desktop-months-container']//div[1]"
        )
        allValidDates = calMonth.find_elements(By.CLASS_NAME,
                                               "uitk-new-date-picker-day")
        for date in allValidDates:
            #print(date.get_attribute("data-day"))
            if date.get_attribute("data-day") == "30":
                date.click()
                break
        Listobtn = hw.getElement("//span[contains(text(),'Listo')]", "xpath")
        Listobtn.click()

        Buscarbtn = hw.getElement(
            "//button[@class='uitk-button uitk-button-large uitk-button-fullWidth uitk-button-has-text uitk-button-primary']",
            "xpath")
        Buscarbtn.click()

        _currentUrl = driver.current_url
        print(str(_currentUrl))
        # Browser Close
        time.sleep(5)
        driver.quit()