Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 3.x 元素在"//div[包含(@class,“连接内容”)]//选择;不可点击_Python 3.x_Selenium Webdriver_Firefox_Geckodriver_Python Behave - Fatal编程技术网

Python 3.x 元素在"//div[包含(@class,“连接内容”)]//选择;不可点击

Python 3.x 元素在"//div[包含(@class,“连接内容”)]//选择;不可点击,python-3.x,selenium-webdriver,firefox,geckodriver,python-behave,Python 3.x,Selenium Webdriver,Firefox,Geckodriver,Python Behave,我正在尝试在web应用程序(Angular2、https和websocket)上运行一些自动化测试,包括:gherkin、behave 1.2.6、selenium 3.141.0、firefox和python 3.9.4、geckodriver 0.29.1、allure behave 2.8.40 配置: user_agent=“Mozilla/5.0(Windows NT 10.0;Win64;x64;rv:87.0)Gecko/20100101 Firefox/87.0” 定位器: se

我正在尝试在web应用程序(Angular2、https和websocket)上运行一些自动化测试,包括:gherkin、behave 1.2.6、selenium 3.141.0、firefox和python 3.9.4、geckodriver 0.29.1、allure behave 2.8.40

配置: user_agent=“Mozilla/5.0(Windows NT 10.0;Win64;x64;rv:87.0)Gecko/20100101 Firefox/87.0”

定位器: select=(By.XPATH,'//div[包含(@class,“连接内容”)]//select')

错误: 断言失败:在当前页面中找不到项目“profilselect.select”,无法在其上设置值 捕获的日志记录:警告:root:[ACTION]waitForClickable=>位于“//div[contains(@class,“连接内容”)]///select”的元素不可单击

我要选择的Html选项:请注意,不能使用«值»,因为我只对«选项»标记之间的文本感兴趣,仅当给定文本对应于所选的特定值时

既然您的元素本身是select类型,为什么不使用Selenium select类,这样您就可以通过文本或索引直接与之交互。

既然您没有显示代码,我只能帮助您使用伪代码:

we_sel = WebDriverWait(driver, 10).until(expected_conditions.visibility_of_element_located((By.ID, 'form-1-1'))

# The above statement is equivalent to below statement.

# If you are not familiar with WebDriver Waits then uncomment the below statement and comment the above statement.

# we_sel = driver.find_element_by_id('form-1-1')

sel = Select(we_sel)
sel.select_by_visible_text('replace withoption text u want to select')
参考(Webdriver API文档):

  • 对于
    选择
    类:
    

  • 对于
    WebDriverWait
    类:

  • 对于
    预期条件
    模块:


  • 拜托,你能告诉我怎么做吗?一个示例代码…@Bizi这应该对你有帮助