def load(self, directory: str) -> None: file_list = os.listdir(directory) if os.path.exists( directory) and os.path.isdir(directory) else list() file_list = sorted(file_list) for file in file_list: match_result = re.match(r'(\d+)_actions\.json', file) if match_result: timestamp = match_result.group(1) before_page = Page() before_page.load( os.path.join(directory, "{}_src_layout.json".format(timestamp))) if self.origin_page.is_empty(): self.origin_page = before_page after_page = Page() after_page.load( os.path.join(directory, "{}_dst_layout.json".format(timestamp))) action = Action() action.load( os.path.join(directory, "{}_actions.json".format(timestamp))) action.add_page((before_page, after_page)) self.action_list.append(action)
def test_case_1(browser): page = Page(browser) # Navigate to the URL https://www.sogeti.com/ page.load() # Hover over Services Link page.hover('//*[@id="header"]/div[1]/nav/ul/li[3]/div') # and then Click Automation link. page.click('//*[@id="header"]/div[1]/div[5]/ul/li[7]/a') # Verify that Automation Screen is displayed assert 'Automation' in page.title() # and “Automation” text is visible in Page assert 'Automation' in page.get_attribute_of_element( '//*[@id="primary_content"]/div/div[2]/div/h1/span', 'textContent') # Hover again over Services Link page.hover('//*[@id="header"]/div[1]/nav/ul/li[3]/div') # Verify that the Services and Automation are selected assert 'selected' in page.get_attribute_of_element( '//*[@id="header"]/div[1]/div[5]/ul/li[7]', 'class')
def import_page(self, page: Page, page_key, table, table_folder, num_base_pages=None): inner_idx, pr_idx = page_key try: binary_file = open( self.database_folder + "/" + table_folder + "/" + "pagerange_" + str(pr_idx), 'rb') except FileNotFoundError: return False if num_base_pages == None: num_base_pages = table.page_ranges[pr_idx].base_page_count offset = self.get_page_offset_in_pr(page_key, num_base_pages) # Read num_records binary_file.seek(offset) num_records = ifb(binary_file.read(8)) # Read data data = bytearray(binary_file.read(PAGE_SIZE)) page.num_records = num_records page.load(data, num_records) # todo: is_dirty, pinning binary_file.close()
def decode_page(BYTES_page) -> Page: page = Page(True) # type: Page # data, num_records=None, is_dirty=None, force=False): # is_loaded = True num_records = int_from_bytes(BYTES_page[0:8]) data = bytearray(BYTES_page[8:]) page.load(data, num_records) return page
def test_case_3(browser): page = Page(browser) # Navigate to the URL https://www.sogeti.com/ page.load() # Click the Worldwide Dropdown link in Page Header. page.click('//*[@id="header"]/div[1]/div[2]/div[2]/div[2]') # A Country dropdown list is displayed. assert True == page.is_displayed('//*[@id="header"]/div[3]') # Assert that all the Country specific Sogeti links are working. for link in page.get_links('//*[@id="header"]/div[3]'): assert 200 == requests.head(link.get_attribute('href')).status_code
def test_case_1(browser): page = Page(browser) # Navigate to the URL https://www.sogeti.com/ page.load() # Hover over Services Link page.hover('//*[@id="header"]/div[1]/nav/ul/li[3]/div') # and then Click Automation link. page.click('//*[@id="header"]/div[1]/div[5]/ul/li[7]/a') # On Automation Page, scroll down to the Contact us Form. page.scroll_into_view('//*[@id="99a12a58-3899-4fe1-a5c7-b9065fe635b0"]') # Fill the First Name with Random Generated Data. page.input_to('//*[@id="4ff2ed4d-4861-4914-86eb-87dfa65876d8"]', 'test') # Fill the Last Name with Random Generated Data page.input_to('//*[@id="11ce8b49-5298-491a-aebe-d0900d6f49a7"]', 'test') # Fill the Email with Random Generated Data page.input_to('//*[@id="056d8435-4d06-44f3-896a-d7b0bf4d37b2"]', '*****@*****.**') # Fill the Phone with Random Generated Data page.input_to('//*[@id="755aa064-7be2-432b-b8a2-805b5f4f9384"]', 'test') # Fill the Message with Random Generated Data page.input_to('//*[@id="88459d00-b812-459a-99e4-5dc6eff2aa19"]', 'test') # Check the I agree checkbox. page.click('//*[@id="863a18ee-d748-4591-bb64-ef6eae65910e"]/label/input') # Then Click SUBMIT button. page.click('//*[@id="06838eea-8980-4305-83d0-42236fb4d528"]') # After clicking SUBMIT button the form is submitted and Thank you message is displayed. Assert the Thank you message assert 'Thank you for contacting us.' in page.get_attribute_of_element( '//*[@id="99a12a58-3899-4fe1-a5c7-b9065fe635b0"]/div[1]/div/p', 'textContent')
def post(self, page_name): """Request POST handling method This method handles all the POST requests to wiki pages. It's almost same as GET method. """ page = Page.load(page_name) page.name = self.request.get("name") page.post_requests[u"content"] = self.request.get("content") page.post_requests[u"format"] = self.request.get("format") page.save() self.redirect(page.path[u"view"])
one_node_b = page_b.get_node_by_id(ori_id) if one_node_b is None: logging.warning("Node {} not found!".format(ori_id)) else: result.append(one_node_b) return result if __name__ == "__main__": device = Device("") while True: crt_page = Page(0) crt_page.load_from_device(device) page_1 = Page(0) # page_1.load("./data/wechat001/3/1610937568512_dst_layout.xml") page_1.load("./data/wechat_red_packet/1614315716354_src_layout.json") # interested_node = page_1.get_node_by_cond(lambda node: '@text' in node.content and node.content['@text'] == "通讯录") with open("./data/wechat_red_packet/1614315716354_actions.json", 'r') as f: action_content = json.load(f)[0] interested_node = page_1.get_node_by_id(action_content['targetNodeId']) strings_path = os.path.abspath("./strings/wechat_strings.txt") cluster_dir = os.path.abspath("./data/wechat001") identifier = Identifier(strings_path, cluster_dir) idx = identifier.get_page_cluster_index_from_page(page_1) print(idx) # crt_page = Page(0) # crt_page.load("./tmp.json") # crt_page_cluster = identifier.get_page_cluster_pointer(crt_page) # idx = identifier.get_page_cluster_index_from_page(crt_page) #
def delete(self, page_name): """Request DELETE handling method""" page = Page.load(page_name) page.remove()