python - 没有选择语句的下拉列表 - 能够单击值,但未设置值
问题描述
我试图从没有“选择”标签的下拉列表中选择多个值。使用下面的代码,我试图从下拉列表中选择 2 个值(追加销售,价格增加),并且我成功地点击了它。但问题是没有选择值并且它只是突出显示并且控件不会转到另一个对象,比如页面中提到的 GO 按钮。请参阅附件,期望值是这样的
driver.find_element_by_xpath("//div[contains(@id,'select-cBooking_Type_NL_CS_US')]").click()
OppType=driver.find_elements_by_xpath("//*[@id='menu-Booking_Type_NL_CS_US']/div[3]/ul/li")
for e in OppType:
if e.text == 'Upsell' or e.text == 'Price Increase':
e.click()
driver.find_element_by_xpath("//span[contains(text(),'GO')]").click()
解决方案
推荐阅读
- html - 您如何将 img 放置在 HTML 和 css 中的 div 上方
- algorithm - 将矩形放置在多边形内的算法
- javascript - Ruby on Rails 表单添加带有文本框的“其他”选项以选择下拉菜单
- nginx - 安全链接模块 NGINX 中的文件名
- html - 当我切换到按月/按年计费时,我得到“NaN”作为文本内容。否则,我的 JS 代码运行良好。我的代码片段附在下面
- python - 更新 Discord 中已存在的嵌入消息
- reactjs - 如果没有找到值,如何返回对象,否则使用条件循环并使用反应和打字稿返回对象?
- ios - Swift - 使用 snapkit 的滚动视图中的 pageviewcontroller 表视图
- sql-server - 使用 SSIS 包将带有嵌套节点的 XML 导入 SQL Server 数据库,并将文件中的记录 ID 添加到每个插入
- javascript - 当名称和值位于不同的 XML 节点中时,使用 Javascript 从 XML 中的某些节点解析属性?