未完成。修改为用js通过xpath获取元素

This commit is contained in:
g1879 2020-10-30 12:45:56 +08:00
parent 9e3f22e47d
commit 0077885ce4

View File

@ -248,7 +248,7 @@ class DriverElement(DrissionElement):
loc_str = loc_or_str[1] if loc_or_str[1].startswith(('.', '/')) else f'.//{loc_or_str[1]}' loc_str = loc_or_str[1] if loc_or_str[1].startswith(('.', '/')) else f'.//{loc_or_str[1]}'
loc_str = loc_str if loc_str.startswith('.') else f'.{loc_str}' loc_str = loc_str if loc_str.startswith('.') else f'.{loc_str}'
loc_or_str = loc_or_str[0], loc_str loc_or_str = loc_or_str[0], loc_str
else: elif loc_or_str[0] == 'css selector':
if loc_or_str[1].lstrip().startswith('>'): if loc_or_str[1].lstrip().startswith('>'):
loc_or_str = loc_or_str[0], f'{self.css_path}{loc_or_str[1]}' loc_or_str = loc_or_str[0], f'{self.css_path}{loc_or_str[1]}'
@ -494,6 +494,9 @@ def execute_driver_find(page_or_ele: Union[WebElement, WebDriver],
mode = mode or 'single' mode = mode or 'single'
if mode not in ['single', 'all']: if mode not in ['single', 'all']:
raise ValueError("Argument mode can only be 'single' or 'all'.") raise ValueError("Argument mode can only be 'single' or 'all'.")
if loc[0] == 'xpath':
pass
else:
try: try:
wait = WebDriverWait(page_or_ele, timeout=timeout) wait = WebDriverWait(page_or_ele, timeout=timeout)
if mode == 'single': if mode == 'single':