Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法为python selenium选择下拉按钮_Selenium_Xpath - Fatal编程技术网

无法为python selenium选择下拉按钮

无法为python selenium选择下拉按钮,selenium,xpath,Selenium,Xpath,如何选择此按钮 然后点击它? 我尝试了几种方法,但没有一种方法成功 你试过类名选择器了吗 element = driver.find_element_by_class_name("btn-select nowrap-line") 我知道您说过您已经尝试了几种方法,可能列出了不同的方法,我可能会尝试查看失败的原因尝试使用css选择器和javaScript executor for select multi class element并单击它 driver.execute_script("doc

如何选择此按钮

然后点击它?

我尝试了几种方法,但没有一种方法成功

你试过类名选择器了吗

element = driver.find_element_by_class_name("btn-select nowrap-line")

我知道您说过您已经尝试了几种方法,可能列出了不同的方法,我可能会尝试查看失败的原因

尝试使用css选择器和javaScript executor for select multi class element并单击它

driver.execute_script("document.querySelector('button.btn-select.nowrap-line')[0].click()")

这不起作用,因为不允许使用复合类名。这不起作用,我第一次尝试了这个。你怎么尝试的?共享您当前的代码并描述问题/共享异常日志共享您目前的试用代码,dropDown=browser。通过xpath('//div[contains(@class,\'btn btn select nowrap line\')][contains(@tabindex,\'1\')])查找\u element\u。单击()这是我最近尝试的一个,但不起作用。请添加一些解释。当我输入它时,它不起作用,你还有其他方法吗?或者你能再解释一下吗