powershell - 带有 Selenium 的 Powershell:选择下拉项
问题描述
我正在使用带有 Selenium 的 Powershell,需要从下拉列表中选择一个项目。该页面是https://app.beefy.finance/。我需要将“Vault Type”从“ALL”更改为“Single assets”
$browser = Start-SeChrome
$URL = "https://app.beefy.finance/"
$browser.Navigate().GoToURL($URL)
#----- Wait statements here ------
$Select_Option = $browser.FindElementById("select-vault-type")
#At this stage I have tried the following commands but they all error out:
Set-SeSelectValue -By Value -value 'Single Assets' -Element $Select_Option
$Select_Option.SelectByValue('Single Assets')
$Select_Option.Text('Single Assets')
我什至尝试过使用 xpath,但也失败了
解决方案
您需要单击下拉列表才能显示对象。然后你可以找到它并点击它。我使用它的 XPath:
$browser = Start-SeChrome
$URL = "https://app.beefy.finance/"
$browser.Navigate().GoToURL($URL)
#----- Wait statements here ------
$Select_Option = $browser.FindElementById("select-vault-type")
$Select_Option.Click()
$Select_Option.FindElementByXPath('/html/body/div[4]/div[3]/ul/li[2]').Click()
推荐阅读
- kubernetes - Google Kubernetes Engine 中的工作节点限制
- entity-framework - 如何在 ORM 中实现一致的事务?
- javascript - 输入文本框验证在 Vue js 中不起作用
- mysql - 从 datetime 获取单个日期或日期范围下的详细信息的 SQL 查询问题
- vue.js - Konvajs + Vuejs 如何在 vue 中访问舞台宽度
- android - 具有透明左右填充/边距的搜索栏拇指
- java - 这是什么类型的内容/格式(我从 API 获得的响应)?
- java - 如何计算数组中的特定字符 - Java
- sql - SQL查询从具有一对多关系的两个表中获取数据
- ansible - ansible 角色的分子测试 - 如何构建以避免重复