<jupyter_start><jupyter_text>https://www.itread01.com/content/1504789095.html https://stackoverflow.com/questions/35606708/what-is-the-difference-between-and-in-xpath Absolute vs relative XPaths (/ vs .)/ introduces an absolute location path, starting at the root of the document.. introduces a relative location path, starting at the context node.Named element vs any element (ename vs *)/ename selects an ename root element./ename selects all ename child elements of the current node./* selects the root element, regardless of name../* or * selects all child elements of the context node, regardless of name.descendant-or-self axis (//*)//ename selects all ename elements in a document..//ename selects all ename elements at or beneath the context node.//* selects all elements in a document, regardless of name..//* selects all elements, regardless of name, at or beneath the context node.With these concepts in mind, here are answers to your specific questions....//*[@id='Passwd'] means to select all elements at or beneath the current context node that have an id attribute value equal to 'Passwd'.//child::input[@type='password'] can be simplified to //input[@type='password'] and means to select all input elements in the document that have an type attribute value equal to 'password'.\  統計 xxx 節點為 xx<jupyter_code>ele=driver.find_element_by_xpath('//*[count(input)=2]/..')
print(ele.tag_name)
ele=driver.find_element_by_xpath('//*[count(input)=2]/..')
print(ele.tag_name)
ele=driver.find_element_by_xpath('//*[count(input)=1]')
print(ele.tag_name)<jupyter_output>div<jupyter_text>找tag為xxx的元素<jupyter_code>ele=driver.find_element_by_xpath('//*[local-name()="input"]')
print(ele.tag_name)
ele.get_attribute('name')<jupyter_output><empty_output><jupyter_text>找開頭為xxx的元素<jupyter_code>ele=driver.find_element_by_xpath('//*[starts-with(local-name(),"i")]')
print(ele.tag_name)
ele.get_attribute('name')<jupyter_output><empty_output><jupyter_text>找包含為xxx的元素<jupyter_code>ele=driver.find_element_by_xpath('//*[contains(local-name(),"i")]')
print(ele.tag_name)
ele=driver.find_element_by_xpath('//*[contains(local-name(),"i")][last()]')
print(ele.tag_name)
ele.get_attribute('name')<jupyter_output><empty_output><jupyter_text>找長度為xxx的元素<jupyter_code>ele=driver.find_element_by_xpath('//*[string-length(local-name())=6]')
print(ele.tag_name)
ele.get_attribute('name')<jupyter_output><empty_output><jupyter_text>多個路徑查找<jupyter_code>ele=driver.find_element_by_xpath('//title  |  //input[last()]')
print(ele.tag_name)
ele.get_attribute('name')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14558193849746984, 'fraction_numerical': 0.009342156481121059, 'mean_word_length': 7.132911392405063, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '18846', 'license': 'MIT', 'n_tokens_mistral': 897, 'n_tokens_neox': 886, 'n_words': 187, 'path': 'RPA/selenium/selenium_xpath.ipynb', 'repo_name': 'erik1110/postgres', 'size': '2569'}