小编anf*_*eld的帖子

Python Selenium 右键单击

试图找到一些文本,然后右键单击该文本。该表是动态的,因此我无法假设知道要搜索的值所在的单元格位置或要单击的值。例如,我想找到一个名称,然后右键单击名称本身

右键菜单似乎被称为class = context menu,值为class = context_item(请参见附加的屏幕截图)(还包括 html)

我知道这部分有效,但它下面的其余部分有问题 - col = row.find_element(By.XPATH, '//a[contains(text() , "Luke Wilson")]')

### 输出

回溯(最近一次调用):文件“C:\Users\AppData\Local\Programs\Python\Python36\ffox_Change_Create_Save_Stay_v2.py”,第 182 行,在 get_all_rows_approval() 文件“C:\Users\AppData\Local\Programs\ Python\Python36\ffox_Change_Create_Save_Stay_v2.py”,第 164 行,在 get_all_rows_approval 菜单 = col.find_element_by_class_name("context_menu") 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\web \remote\webelement.py", line 398, in find_element_by_class_name return self.find_element(by=By.CLASS_NAME, value=name) File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages \selenium\webdriver\remote\webelement.py",第 654 行,在 find_element {"using": by, "value": value})['value'] 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py”,第 628 行,在 _execute 中返回 self._parent.execute(command, params ) 文件“C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 320 行,在执行 self.error_handler.check_response(response) 文件中“ C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py”,第 242 行,在 check_response 中引发 exception_class(message, screen, stacktrace) selenium.common。 exceptions.NoSuchElementException:消息:无法定位元素:.context_menu在 _execute 中返回 self._parent.execute(command, …

python selenium contextmenu python-3.x selenium-webdriver

5
推荐指数
1
解决办法
7210
查看次数