示例#1
0
    def addDocumentCard(self, document1Path, time):

        wait = WebDriverWait(driver, time)
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
        ).click()

        print "Clicking on Add card + icon"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[4]/div[1]/div"
        ).click()

        print "Selecting the Document card"
        driver.find_element_by_css_selector('input[type="file"]').send_keys(
            document1Path)
        print "Uploading document file"

        #wait till minimize button is displayed
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/div[1]/button[1]"
            )))

        downloadButtonLocator = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[2]/div/div/div[1]/div/a")

        if (downloadButtonLocator.is_displayed()):
            print "The file has been uploaded successfully"
        else:
            print "Failed to upload the file"
            raise Exception
示例#2
0
 def addDocumentCardforedit(self,time):
     
     wait=WebDriverWait(driver, time)
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div").click()
     
     print "Clicking on Add card + icon"   
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[4]/div[1]/div").click()
     
     print "Selecting the Document card"
     
     book=xlrd.open_workbook(os.path.join('TestData.xlsx'))
     first_sheet = book.sheet_by_name('MultiCardLesson')
     cell8= first_sheet.cell(1,9)
     document1Path = cell8.value 
     
     driver.find_element_by_css_selector('input[type="file"]').send_keys(document1Path)
     print "Uploading document file"
     
     #wait till minimize button is displayed
     wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/div[1]/button[1]")))
     
     downloadButtonLocator= driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[2]/div/div/div[1]/div/a")
     
     if (downloadButtonLocator.is_displayed()):
         
         print "The file has been uploaded successfully"
     else:
         print "Failed to upload the file"
         raise Exception
def wait_css_clickable(css):
    wait.until(
        selenium.webdriver.support.expected_conditions.element_to_be_clickable(
            (
                selenium.webdriver.common.by.By.CSS_SELECTOR,
                css,
            )))
def wait_css_gone(css):
    wait.until(
        selenium.webdriver.support.expected_conditions.
        invisibility_of_element_located((
            selenium.webdriver.common.by.By.CSS_SELECTOR,
            css,
        )))
示例#5
0
def follow_func(wait, driver, follow_report):
    fol_rep = follow_report

    print(fol_rep)
    sleep(5)
    followButton = wait.until(
        EC.element_to_be_clickable(
            (By.XPATH, '//button[contains(text(),"Follow")]')))

    if (followButton.text != 'Following'):
        followButton.click()
        time.sleep(2)
        print("Click oN  Follow Button")
        fol_rep += 1
        print(fol_rep)

        try:
            res = wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//button[contains(text(),"OK")]')))
            if res.is_displayed():
                print('Follow Restrict')
                fol_rep -= 1
                print(fol_rep)
        except:
            print('Follow Successfully')
            # follow_report -= 1

    else:
        print("You are already following this user")

    return fol_rep
示例#6
0
    def publishLesson(self, lesson_title):

        wait = WebDriverWait(driver, 60)
        #wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
        #wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']")))

        wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
            )))
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/button"
        ).click()
        print "Clicking on READY TO PUBLISH button"

        #wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]")))
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[1]/div[3]/div[3]/div/div[1]/section[3]/div/button[1]"
        ).click()
        print "Clicking on PUBLISH button"

        #print "Validating the success message after publish"
        #wait=WebDriverWait(driver, 60)
        #wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[2]/div/div/span[2]")))
        #actual_success_message= driver.find_element_by_xpath(".//*[@id='content']/div/div/div[2]/div/div/span[2]").text
        #expected_success_message= "You have successfully published \"" + lesson_title + "\"";

        #if(expected_success_message==actual_success_message):

        # print "The success message is displaying as"+ " "+expected_success_message

        #else:

        #print "The success message is not displaying as expected"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[1]/a"
        ).click()
        print "Clicking on EXIT button"

        print "Verifying lesson displayed in Grid"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "(//tbody/tr/td[2]/a[.='" + lesson_title + "'])[1]")))

        if driver.find_element_by_xpath("(//tbody/tr/td[2]/a[.='" +
                                        lesson_title +
                                        "'])[1]").is_displayed():

            print "Lesson is displayed in Grid ::" + lesson_title

        else:
            print "Lesson not displaying in grid"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div[3]/div[1]/div/nav/div/div[4]").click(
            )
def main(argv):
  driver = selenium.webdriver.Chrome()
  wait = selenium.webdriver.support.wait.WebDriverWait(driver, 30)
  driver.get(argv[1])
  wait.until(lambda d: d.find_element_by_id('references'))
  source = driver.page_source
  driver.quit()
  sys.stdout.write(source.encode('ascii', 'xmlcharrefreplace'))
示例#8
0
 def ele_click(self, field, xpath = False):
     if(xpath) :
         wait = WebDriverWait(self.driverMain, 10)
         wait.until(EC.presence_of_element_located((By.XPATH, field)), "")
         self.driverMain.find_element_by_xpath(field).click()
     else:
         wait = WebDriverWait(self.driverMain, 3)
         wait.until(EC.presence_of_element_located((By.ID, field)), "")
         self.driverMain.find_element_by_id(field)
 def ele_click(self, field, xpath=False):
     if (xpath):
         wait = WebDriverWait(self.driverMain, 10)
         wait.until(EC.presence_of_element_located((By.XPATH, field)), "")
         self.driverMain.find_element_by_xpath(field).click()
     else:
         wait = WebDriverWait(self.driverMain, 3)
         wait.until(EC.presence_of_element_located((By.ID, field)), "")
         self.driverMain.find_element_by_id(field)
示例#10
0
 def handle_google_login(self):
     self.switch_to_window(GOOGLE_SIGNIN_TITLE)
     emailField = self.driverMain.find_element_by_id(GOOGLE_EMAIL_FIELD_NAME)
     emailField.send_keys(GOOGLE_LOGIN_EMAIL)
     self.driverMain.find_element_by_id(GOOGLE_NEXT_FIELD_NAME).click()
     PassWordField = self.driverMain.find_element_by_id(GOOGLE_PASS_FIELD_NAME)
     PassWordField.setFocus()
     PassWordField.send_keys('_PL)OK(IJ*UH-pl0ok9ij')
     SignInField = self.driverMain.find_element_by_xpath(XPATH_SIGNIN_BUTTON)
     wait = WebDriverWait(self.driverMain, 3)
     wait.until(EC.visibility_of_element_located(SignInField), "")
     SignInField.click()
示例#11
0
 def addImageCardforedit(self,time):
     
     wait=WebDriverWait(driver, time)
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div").click()
     
     print "Clicking on Add card + icon"
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[2]/div[1]/div").click()
     
     print "Image card selected"
     wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/h4/div[1]/span[2]/div")))
     #driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/h4/div[1]/span[2]/div").click()
     #print "Clicking on browse for your file link"
  
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']"))) 
     
     book=xlrd.open_workbook(os.path.join('TestData.xlsx'))
     first_sheet = book.sheet_by_name('MultiCardLesson')
     cell6= first_sheet.cell(1,5)
     Imagefilepath1 = cell6.value 
     
     
     
     print "Going to upload the image file"
     driver.find_element_by_css_selector('input[type="file"]').send_keys(Imagefilepath1)
     wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img")))
     
     imageContainerlocator_after1upload= driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img")
     
     if(imageContainerlocator_after1upload.is_displayed()):
         print 'Successfully uploaded the image1 file'
     else:
         print "Failed to upload the image1 file"
         raise Exception 
示例#12
0
    def lessonWithTextCard(self, TextContent):

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
        ).click()
        print "Clicking on Add card + icon"

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[1]/div[1]/div"
        ).click()
        print "Clicking on Text card"

        wait = WebDriverWait(driver, 60)
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))
        element = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div"
        )
        webdriver.ActionChains(driver).move_to_element(
            element).click().send_keys(TextContent).perform()
        print "Entering the text as" + " " + TextContent
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))
 def handle_google_login(self):
     self.switch_to_window(GOOGLE_SIGNIN_TITLE)
     emailField = self.driverMain.find_element_by_id(
         GOOGLE_EMAIL_FIELD_NAME)
     emailField.send_keys(GOOGLE_LOGIN_EMAIL)
     self.driverMain.find_element_by_id(GOOGLE_NEXT_FIELD_NAME).click()
     PassWordField = self.driverMain.find_element_by_id(
         GOOGLE_PASS_FIELD_NAME)
     PassWordField.setFocus()
     PassWordField.send_keys('_PL)OK(IJ*UH-pl0ok9ij')
     SignInField = self.driverMain.find_element_by_xpath(
         XPATH_SIGNIN_BUTTON)
     wait = WebDriverWait(self.driverMain, 3)
     wait.until(EC.visibility_of_element_located(SignInField), "")
     SignInField.click()
示例#14
0
def like_func(wait, driver):
    # sleep(5)
    like_button = wait.until(
        EC.element_to_be_clickable(
            (By.XPATH, '//*[@aria-label="Like"]'))).click()
    # sleep(5)
    print('Pic Liked Successfully : ')
    def test_scrape_the_sites(self):
        car_sites_dict = []
        wait = WebDriverWait(self.driver, 20)

        self.driver.get('https://www.copart.com')
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()

        wait.until(
            EC.presence_of_element_located((By.XPATH, "//div[@ng-if='popularSearches']")))
        popular_array = self.driver.find_elements_by_xpath("//div[@ng-if='popularSearches']//ul/li/a")
        count = 0

        while count < len(popular_array):
            pair_list = []
            car_model = popular_array[count].text
            pair_list.append(car_model)

            href = popular_array[count].get_attribute("href")
            pair_list.append(href)

            # add pair_array to array of arrays
            car_sites_dict.append(pair_list)
            count += 1
        print(car_sites_dict)

        count = 0
        while count < len(car_sites_dict):
            pair = car_sites_dict[count]
            car_model = pair[0]
            car_site = pair[1]

            try:
                self.driver.get(car_site)
                self.driver.implicitly_wait(10)

                wait.until(
                    EC.visibility_of_element_located((By.CSS_SELECTOR, "table#serverSideDataTable tbody")))
                body = self.driver.find_element_by_css_selector("table#serverSideDataTable tbody").text
                self.assertIn(car_model, body)

            except:
                screen_name = "{0}-{1}Error".format(car_model, car_site)
                self.driver.save_screenshot("{0}.png".format(screen_name))
                err = car_model + 'NotFound!'
                print('Error Thrown: ', err)
            count += 1
示例#16
0
    def createEvent(self):
        driver.find_element_by_id("mat-checkbox-1").click()
        driver.find_element_by_xpath("//button[@id='0']/span").click()

        wait.until(EC.number_of_windows_to_be(2))
        # Recorrelas hasta encontrar el controlador de la nueva ventana
        for win_ser_1 in driver.window_handles:
            if win_ser_1 != win_ser_local:
                driver.switch_to.window(win_ser_1)
                break
        driver.close()

        cont = 100
        i = 1
        # Cambia el controlador a la ventana o pestana original
        driver.switch_to.window(win_ser_local)
        time.sleep(3)
示例#17
0
def define_contact_and_message(target, message_string):

    wait = WebDriverWait(driver, 600)

    x_arg = '//span[contains(@title,' + target + ')]'
    group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg)))
    group_title.click()

    send_message(message_string)
 def createTagForTrackLessonTwoTextImageVideoDocumentQuestion(self):
     try:
         obj2 = CreateTagTrackLessonTwoTextImageVideoDocumentQuestion()
         obj2.createTrackLessonTwoTextImageVideoDocumentQuestionTag()
     finally:
         print "clicking on Home"
     book = xlrd.open_workbook(os.path.join('TestData.xlsx'))
     first_sheet = book.sheet_by_name('Login_Credentials')
     print("Fetching the Attribute Name from Excel Sheet\n")
     # read a cell
     cell = first_sheet.cell(1, 1)
     HomeURL = cell.value
     print HomeURL
     driver.get(HomeURL)
     wait = WebDriverWait(driver, 80)
     wait.until(
         EC.visibility_of_element_located((By.ID, "global-header-search")))
     print "Home Page Loaded"
示例#19
0
    def get_results(self):
        print(
            len(self.driver.find_elements_by_xpath(self.paginationNumberPath)))
        """
        Get all the rows from the current pagination dashlet
        :return:
        """

        columns = self.get_colum_info()

        data = {}

        # wait for element to appear, then hover it
        wait = WebDriverWait(self.driver, 10)
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                '//*[@id="Dashboard0901-SearchTemplate03"]/form/table/tbody')))

        elements = self.driver.find_elements_by_xpath(self.dashlet_path)

        print('obtengo  ', len(elements), 'elementos del path')

        for element in elements:
            current_index = elements.index(element) + 1
            print('CURRENT INDEX: ', current_index)

            parsed_data = {}

            # print('element index', current_index  )
            for column in columns:
                value = element.find_element_by_xpath(
                    '//*[@id="Dashboard0901-SearchTemplate03"]/form/table/tbody/tr[{}]/td[{}]'
                    .format(current_index,
                            columns.index(column) + 1)).text

                parsed_data.update({column: str(value)})
            data.update({current_index + self.last_key: parsed_data})
        self.last_key = len(elements)
        print('ultimo len antes de actualizar ', self.last_key)
        self.tickets.update(data)
示例#20
0
    def test6(self):

        self.browser.get(url=baseURL)

        wait = WebDriverWait(self.browser, 10)
        wait.until(EC.url_matches(baseURL))
        source = self.browser.find_element_by_id("src-field")
        destination = self.browser.find_element_by_id("dst-field")
        submit = self.browser.find_element_by_id("Search")

        source.send_keys("Chicago")
        destination.send_keys("400 East 30th Austin")

        submit.click()
        # wait.until(EC.presence_of_element_located('lots'))
        time.sleep(10)
        lots = self.browser.find_element_by_id('lots')
        lots.click()

        self.assertTrue(self.browser.current_url.startswith("https://www.google.com/maps"),"Parking Redirection Didnt work")
        print("TEST 6 Parking redirect PASSED")
示例#21
0
 def addVideoCardforedit(self,time):
     
     wait=WebDriverWait(driver, time)
     wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div")))
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div").click()
     
     print "Clicking on Add card + icon"
     driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[3]/div[1]").click()
     
             
     book=xlrd.open_workbook(os.path.join('TestData.xlsx'))
     first_sheet = book.sheet_by_name('MultiCardLesson')
     cell7= first_sheet.cell(1,8)
     videoName = cell7.value 
     
     
     
     #Uploading Video
     print "Uploading Video"
     driver.find_element_by_css_selector('input[type="file"]').send_keys(videoName)
     wait.until(EC.visibility_of_element_located((By.XPATH,"html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button")))
     
     videoContainerlocator_afterupload= driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button")
     
     if(videoContainerlocator_afterupload.is_displayed()):
         print 'Successfully uploaded the Video file'
     else:
         print "Failed to upload the Video file"
         raise Exception
     
     driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button").click()
     wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div")))
示例#22
0
    def next_pagination(self, counter):
        print('entrando a next pagination: ', counter)

        time.sleep(1)
        try:

            next_page = WebDriverWait(self.driver, 10).until(
                EC.element_to_be_clickable(
                    (By.XPATH, self.dashlet +
                     '//span//a[contains(text(), "{}")]'.format(counter))))
            next_page.click()
            print('dì clic')
            time.sleep(5)
            wait.until(
                EC.visibility_of_element_located((
                    By.XPATH,
                    '//*[@id="Dashboard0901-SearchTemplate03"]/form/table/tbody'
                )))

        except Exception as e:
            flag = False
            print("no more pagination")
示例#23
0
    def addImageCard(self, Imagefilepath1, linkname, Imagefilepath2, time):

        wait = WebDriverWait(driver, time)
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
        ).click()

        print "Clicking on Add card + icon"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[2]/div[1]/div"
        ).click()

        print "Image card selected"
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/h4/div[1]/span[2]/div"
            )))
        #driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/h4/div[1]/span[2]/div").click()
        #print "Clicking on browse for your file link"

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))

        print "Going to upload the image file"
        driver.find_element_by_css_selector('input[type="file"]').send_keys(
            Imagefilepath1)
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img"
            )))

        imageContainerlocator_after1upload = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/img"
        )

        if (imageContainerlocator_after1upload.is_displayed()):
            print 'Successfully uploaded the image1 file'
        else:
            print "Failed to upload the image1 file"
            raise Exception
示例#24
0
 def Logincreateuser(self):
     print "Reading data from excel sheet"
     book = xlrd.open_workbook(os.path.join('TestData.xlsx'))
     sheet1 = book.sheet_by_name('API testing')
     cell2 = sheet1.cell(1, 2)
     Currentpassword = cell2.value
     cell3 = sheet1.cell(1, 3)
     Newpassword = cell3.value
     wait = WebDriverWait(driver, 80)
     print "Grovo Sign-In page is displayed"
     print "Enter User name"
     driver.find_element_by_id("username").send_keys(email)
     print "Enter Password"
     element = WebDriverWait(driver, 10).until(
         EC.presence_of_element_located((By.ID, "password")))
     element.send_keys(Currentpassword)
     element.send_keys(Keys.TAB)
     print "Clicking on Sign_In button"
     driver.find_element_by_xpath("//*[@id='submitButton']").click()
     wait.until(EC.visibility_of_element_located(
         (By.ID, "currentPassword")))
     driver.find_element_by_id("currentPassword").send_keys(Currentpassword)
     print "Current Password is entered :" + Currentpassword
     driver.find_element_by_id("newPassword").send_keys(Newpassword)
     print "New Password is entered :" + Newpassword
     wait.until(
         EC.visibility_of_element_located(
             (By.XPATH,
              "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button")))
     driver.find_element_by_xpath(
         "html/body/div[2]/div/div/div[2]/div[1]/div[2]/button").click()
     wait.until(
         EC.visibility_of_element_located(
             (By.XPATH,
              ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[2]/span")))
     print "Home Page is Loaded"
     expectedresult = "Home"
     expectedresult1 = "Library"
     actualresult = driver.find_element_by_xpath(
         ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[2]/span").text
     actualresult1 = driver.find_element_by_xpath(
         ".//*[@id='content']/div/div[1]/div/nav/div[1]/a[3]/span").text
     if (expectedresult == actualresult):
         if (expectedresult1 == actualresult1):
             print "User is able to login and Dashboard is displayed.."
     else:
         print "User not able to login.."
         raise Exception
         print Exception
     wait = WebDriverWait(driver, 80)
     print "Sign out "
     ele = driver.find_element_by_xpath(
         ".//*[@id='content']/div/div[1]/div[1]/nav/div[2]/a/span[3]")
     driver.execute_script('arguments[0].click()', ele)
     elem = driver.find_element_by_xpath(
         "html/body/div/div/div[1]/div[2]/div[2]/a")
     driver.execute_script('arguments[0].click()', elem)
示例#25
0
def story_func(wait, driver, story_report):
    fol_story = story_report
    # try:
    # Story
    print('iiii')
    sleep(5)
    profile = wait.until(
        EC.element_to_be_clickable((
            By.XPATH,
            '/html/body/div[1]/section/main/div/div[1]/article/header/div[2]/div[1]/div[1]/span/a'
        )))

    if profile.is_displayed():
        profile.click()
        sleep(5)
        print('333')
        try:
            Story = wait.until(
                EC.element_to_be_clickable((By.CLASS_NAME, '_6q-tv'))).click()
            time.sleep(5)
            StoryClose = wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '/html/body/div[1]/section/div[3]/button')))
            if StoryClose.is_displayed():
                StoryClose.click()
                print('Story1 Seen Successfully')
                fol_story += 1

                print(fol_story)

        except:
            # fol_story -= 1
            print(fol_story)
            print('Story Not Found')

    return fol_story
示例#26
0
    def addQuestionCard(self, questionCard, ans1, ans2):

        wait = WebDriverWait(driver, 60)
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
            )))
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
        ).click()

        print "Clicking on Add card + icon"
        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[5]/div[1]/div"
        ).click()

        print "Question card selected"
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, ".//*[@id='question-answer-input-0']")))

        print "Entering question"
        ele = driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/p/textarea"
        )
        ele.send_keys(questionCard)

        print "Entering first answer"
        driver.find_element_by_xpath(
            ".//*[@id='question-answer-input-0']").send_keys(ans1)

        print "Entering Second answer"
        driver.find_element_by_xpath(
            ".//*[@id='question-answer-input-1']").send_keys(ans2)

        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//span[@class='lesson-editor-status' and .='Saved']")))
示例#27
0
    def _wait_until_condition(self, condition, wait_time=50):
        """
        Helper to wait for a condition to be fulfilled.

        :param condition: condition to be fulfilled
        :param wait_time: timeout in seconds

        :type condition: selenium.webdriver.support.expected_conditions
        :type wait_time: int

        :returns: instance of WebElement
        :rtype: selenium.webdriver.remote.webelement.WebElement
        """

        if not wait_time:
            wait_time = 15

        wait = WebDriverWait(self._driver, wait_time)
        return wait.until(condition)
示例#28
0
def send_message(message_string):
    wait = WebDriverWait(driver, 600)

    message = driver.find_elements_by_xpath(
        '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]

    message.click()

    message.send_keys(message_string)

    send_button_ref = '//*[@id="main"]/footer/div[1]/div[3]/button'

    sendbutton = wait.until(
        EC.presence_of_all_elements_located((By.XPATH, send_button_ref)))[0]

    sendbutton.click()


# config_whatsapp_bot("/home/alberto/")
# define_contact_and_message("'David Piso Valencia'", "Quieres pito?")
示例#29
0
    def addVideoCard(self, videoName, time):

        wait = WebDriverWait(driver, time)
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
            )))

        driver.find_element_by_xpath(
            ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
        ).click()
        print "Clicking on Add card + icon"

        driver.find_element_by_xpath(
            "html/body/div/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[3]/div[1]"
        ).click()

        #Uploading Video
        print "Uploading Video"
        driver.find_element_by_css_selector('input[type="file"]').send_keys(
            videoName)

        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                "html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button"
            )))

        videoContainerlocator_afterupload = driver.find_element_by_xpath(
            "html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button"
        )

        if (videoContainerlocator_afterupload.is_displayed()):

            print 'Successfully uploaded the Video file'

        else:
            print "Failed to upload the Video file"
            raise Exception

        driver.find_element_by_xpath(
            "html/body/div[1]/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/div[1]/div[1]/button"
        ).click()
        wait.until(
            EC.visibility_of_element_located((
                By.XPATH,
                ".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"
            )))
示例#30
0
def get_inventory(wait: WebDriverWait):
    """

    :param wait: Instance of web driver wait
    :return: List with product information
    """

    item_locator = (By.XPATH, '//div[@class= "inventory_item"]')
    elements: WebElement
    elements = wait.until(EC.visibility_of_all_elements_located(item_locator))
    items_inv = []
    for index, element in enumerate(elements):
        element: WebElement
        title = element.find_element_by_class_name('inventory_item_name').text
        description = element.find_element_by_class_name(
            'inventory_item_desc').text
        price = element.find_element_by_class_name('inventory_item_price').text
        tmp = InventoryItem(title, description, price)
        items_inv.append(tmp)
    return items_inv
示例#31
0
 def lessonWithTextCardforedit(self):   
     
     wait=WebDriverWait(driver, 60)
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div").click()
     
     book=xlrd.open_workbook(os.path.join('TestData.xlsx'))
     first_sheet = book.sheet_by_name('MultiCardLesson')
     cell2= first_sheet.cell(59,1)
     TextContent = cell2.value 
     
     print "Clicking on Add card + icon"  
     driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[1]/div[1]/div").click()
     
     print "Clicking on Text card"    
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']"))) 
     
     element = driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div")
     webdriver.ActionChains(driver).move_to_element(element).click().send_keys(TextContent).perform()
     
     print "Entering the text as"+ " "+TextContent 
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
     wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']"))) 
示例#32
0
    def addQuestionCardforedit(self):
        
        wait=WebDriverWait(driver, 60)
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div"))) 
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div").click()
        
        book=xlrd.open_workbook(os.path.join('TestData.xlsx'))
        first_sheet = book.sheet_by_name('MultiCardLesson')
        
        cell3= first_sheet.cell(59,2)
        questionCard = cell3.value 
        
        cell4= first_sheet.cell(1,3)
        ans1 = cell4.value 
        
        cell5= first_sheet.cell(1,4)
        ans2 = cell5.value 

        
        print "Clicking on Add card + icon"  
        driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[3]/div[2]/div[2]/div/div[2]/div[1]/div[5]/div[1]/div").click()
        
        print "Question card selected"
        wait.until(EC.visibility_of_element_located((By.XPATH,".//*[@id='question-answer-input-0']")))
        
        print "Entering question"
        ele=driver.find_element_by_xpath(".//*[@id='content']/div/div/div[3]/div[1]/div/div[2]/div[2]/div/div/div/div/div/p/textarea")
        ele.send_keys(questionCard)
        
        print "Entering first answer"
        driver.find_element_by_xpath(".//*[@id='question-answer-input-0']").send_keys(ans1)
        
        print "Entering Second answer"
        driver.find_element_by_xpath(".//*[@id='question-answer-input-1']").send_keys(ans2)
          
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saving...']")))
        wait.until(EC.visibility_of_element_located((By.XPATH,"//span[@class='lesson-editor-status' and .='Saved']"))) 
示例#33
0
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC, wait
from selenium.webdriver.support.ui import Select
import urllib2

url = "http://racing4everyone.eu/2016/03/12/formula-e-201516-round05-mexico/"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page.read(), "html.parser")

dropdown = [x.text for x in soup.find_all('option')]

driver = webdriver.Firefox()
wait = WebDriverWait(driver, 10)
driver.get("http://racing4everyone.eu/2016/03/12/formula-e-201516-round05-mexico/")

for x in dropdown:
    print x
    droplist = driver.find_element_by_css_selector("select");
    #droplist.selectByVisibleText(x);
    Select(driver.find_element_by_xpath("//select[option='" + x + "']")).select_by_visible_text(x)
    frame_video = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "iframe[src*=video]")))
    driver.switch_to.frame(frame_video)
    WebDriverWait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".controls")))
    page_source = driver.page_source
    driver.switch_to_default_content()
    driver.close()

    soup = BeautifulSoup(page_source, "html.parser")
    script = soup.find_all("script")
    print script
    # A couple of other operations follow to isolate the relevant data from the script data