コード例 #1
0
 def input_date_time(self, date_time_selected):
     self.driver = SeleniumLibraryExt.create_driver()
     date = self.date_parse(date_time_selected)
     time = self.time_parse(date_time_selected)
     date_time = date + " " + time
     date_time_textbox = self.driver.find_element_by_xpath("//input[@id='dateAndTimePickerInput']")
     self.textbox_parse(date_time_textbox, date_time)
コード例 #2
0
 def insert_data(self, values):
     self.driver = SeleniumLibraryExt.create_driver()
     for key in values:
         if key in self.dict2:
             text_box = self.driver.find_element_by_xpath(self.dict2[key])
             text_box.clear()
             text_box.send_keys(values[key])
     self.driver.find_element_by_xpath("//button[@id='submit']").click()
コード例 #3
0
 def retrieve_rows_per_page(self):
     self.driver = SeleniumLibraryExt.create_driver()
     values_dict = dict()
     values = self.driver.find_elements_by_xpath("//option")
     for elem in values:
         nr_rows = int(elem.get_attribute('value'))
         header = elem.text
         values_dict[nr_rows] = f"//option[text()='{header}']"
     self.dict = values_dict
コード例 #4
0
 def click_selected_button(self, choice):
     self.driver = SeleniumLibraryExt.create_driver()
     source = self.driver.find_element_by_xpath(
         f"//button[text()='{choice}']")
     action = ActionChains(self.driver)
     if choice == "Double Click Me":
         action.double_click(source).perform()
     elif choice == "Right Click Me":
         action.context_click(source).perform()
     elif choice == "Click Me":
         action.click(source).perform()
コード例 #5
0
 def select_date(self, date_selected):
     self.driver = SeleniumLibraryExt.create_driver()
     date_dict = dict()
     self.driver.find_element_by_xpath("//input[@id='datePickerMonthYearInput']").click()
     self.driver.find_element_by_xpath("//select[@class='react-datepicker__month-select']").click()
     date_dict[
         'Month'] = f"//select[@class='react-datepicker__month-select']//option[text()='{date_selected['Month']}']"
     self.driver.find_element_by_xpath("//select[@class='react-datepicker__year-select']").click()
     date_dict[
         'Year'] = f"//select[@class='react-datepicker__year-select']//option[text()='{date_selected['Year']}']"
     date_dict['Day'] = f"//div[text()='{date_selected['Day']}'][not(contains(@class,'--outside-month'))]"
     for key in date_dict:
         self.driver.find_element_by_xpath(date_dict[key]).click()
コード例 #6
0
 def retrieve_radiobuttons(self):
     self.driver = SeleniumLibraryExt.create_driver()
     label_dict = dict()
     xpaths = list()
     ids = list()
     form_1 = self.driver.find_elements_by_xpath("//input[@type='radio']")
     for elem in form_1:
         key = elem.get_attribute('id')
         xpath = f"//input[@type='radio'][@id='{key}']"
         xpaths.append(xpath)
         ids.append(key.lower())
     form_2 = self.driver.find_elements_by_xpath("//label[@class]")
     for i in range(len(form_2)):
         label_dict[form_2[i].text] = xpaths[i]
     self.dict = label_dict
コード例 #7
0
 def retrieve_buttons(self):
     """
     Method used to retrieve all the buttons in the page
     :return:
     """
     self.driver = SeleniumLibraryExt.create_driver()
     label_dict = dict()
     xpaths = list()
     form_1 = self.driver.find_elements_by_xpath(
         "//button[contains(@class,'btn btn-primary')]")
     for elem in form_1:
         name = elem.text
         xpath = f"//button[text()='{name}']"
         xpaths.append(xpath)
         label_dict[name] = xpath
     self.dict = label_dict
コード例 #8
0
 def click_add(self):
     self.driver = SeleniumLibraryExt.create_driver()
     self.driver.find_element_by_xpath("//button[@id='addNewRecordButton']").click()
     labels_webelements = self.driver.find_elements_by_xpath("//form[@id='userForm']//label")
     labels = list()
     dict_value = dict()
     xpaths = list()
     for elem in labels_webelements:
         labels.append(elem.text)
     textboxes = self.driver.find_elements_by_xpath("//form[@id='userForm']//input")
     for elem in textboxes:
         id = elem.get_attribute('id')
         xpath = f"//form[@id='userForm']//input[@id='{id}']"
         xpaths.append(xpath)
     for i in range(len(labels)):
         dict_value[labels[i]] = xpaths[i]
     self.dict2 = dict_value
コード例 #9
0
 def retrieve_data(self):
     self.driver = SeleniumLibraryExt.create_driver()
     columns = self.driver.find_elements_by_xpath("//div[@class='rt-resizable-header-content']")
     column_names = list()
     data = list()
     for i in range(len(columns) - 1):
         column_name = columns[i].text
         column_names.append(column_name)
     rows = self.driver.find_elements_by_xpath("//div[contains(@class,'rt-tr ')]")
     for elem in rows:
         if elem.get_attribute('class') != "rt-tr -padRow -odd" and elem.get_attribute('class') != "rt-tr -padRow " \
                                                                                                   "-even":
             cell = elem.find_elements_by_tag_name("div")
             my_dict = {}
             for i in range(len(cell) - 2):
                 cell_value = cell[i].text
                 my_dict[column_names[i]] = cell_value
             data.append(my_dict)
     print(data)
コード例 #10
0
 def input_date(self, date_selected):
     self.driver = SeleniumLibraryExt.create_driver()
     date = self.date_parse(date_selected)
     date_textbox = self.driver.find_element_by_xpath("//input[@id='datePickerMonthYearInput']")
     self.textbox_parse(date_textbox, date)
コード例 #11
0
 def select_button(self, selection):
     self.driver = SeleniumLibraryExt.create_driver()
     choice = self.driver.find_element_by_xpath(self.dict[selection])
     self.driver.execute_script("arguments[0].click()", choice)
コード例 #12
0
 def select_rows_per_page(self, nr_rows):
     self.driver = SeleniumLibraryExt.create_driver()
     for key in self.dict:
         if nr_rows == key:
             self.driver.find_element_by_xpath(self.dict[key]).click()
             break
コード例 #13
0
 def search(self, search_value):
     self.driver = SeleniumLibraryExt.create_driver()
     search_box = self.driver.find_element_by_xpath("//input[@id='searchBox']")
     search_box.click()
     search_box.send_keys(search_value)