powershell - 带有 Selenium 的 Powershell:我无法让“滚动视图”工作
问题描述
我需要向下滚动页面到NEXT
按钮。只有NEXT
按钮可见才能点击。所以我需要让滚动进入视图才能工作。
$browser = Start-SeChrome
$browser.Navigate().GoToURL($url)
ForEach ($A_Element in (Find-SeElement -Driver $browser -TagName a))
{
If ($A_Element.Text -Notlike "Next"){Conitnue}
$A_Element.ScrollIntoView()
#Invoke-SeClick -Element $A_Element
#$A_Element.Click()
sleep 2
Break
}
解决方案
根据您网页的设计方式,您可以尝试通过以下方式在 PowerShell 代码中执行 JavaScript 代码:
$browser.ExecuteScript("javascript code goes here").
您可以尝试以下方法:
$browser.ExecuteScript("document.scrollTo($($A_Element.Location.X),$($A_Element.Location.Y))")
推荐阅读
- angular6 - Angular 6 从生成使用组件
- mockito - 在 Spring Boot 中未在 Mockito 中注入 Autowired
- apache - 如何使用 haproxy 在具有多个虚拟主机的同一服务器上路由特定虚拟主机
- arkit - RealityKit - 人脸锚
- java - Fineract API Post recurringdepositaccount 不起作用,并且它也没有包含在 Fineract 文档中
- flutter - Flutter Clipper 失败,bool 为 null
- javascript - 我应该在移动键盘上方使用媒体查询和转换: translateY(-%) 吗?
- excel - 如何将唯一值粘贴到指定工作簿中的某些单元格?
- git - 缩短分支
- javascript - Javascript opencv (opencv.js) 抓取 GC_INIT_WITH_MASK 问题示例?