简体   繁体   English

Selenium scrollIntoView()for Internet Explorer吗?

[英]Selenium scrollIntoView() for Internet Explorer?

I want to use selenium scrollIntoView() method for Internet Explorer but this 我想对Internet Explorer使用selenium scrollIntoView()方法,但这

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", _webElement_ );

is not working. 不管用。

And, I have researched on google which says maybe we have to use jquery plugin. 而且,我在Google上进行了研究,说也许我们必须使用jquery插件。 I don't know what to do. 我不知道该怎么办。 Please tell me a way to execute scrollIntoView() in IE11 without any plugin. 请告诉我一种无需任何插件即可在IE11中执行scrollIntoView()的方法。

Try with executing following script 尝试执行以下脚本

window.scroll(0, document.querySelector('css selector goes here').offsetTop);

you could locate elements also by 你也可以通过找到元素

  • document.getElementById(id) Find an element by element id document.getElementById(id)按元素ID查找元素
  • document.getElementsByTagName(name) Find elements by tag name document.getElementsByTagName(name)通过标签名称查找元素
  • document.getElementsByClassName(name) Find elements by class name document.getElementsByClassName(name)按类名称查找元素

Update 更新

another way (using protractor) 另一种方式(使用量角器)

await browser.executeScript(`arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'})`, element);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows Selenium Webdriver Internet Explorer之间切换 - Switch between windows Selenium Webdriver Internet Explorer Javascript Selenium Internet Explorer 11选项 - Javascript Selenium Internet Explorer 11 Options 无法在Selenium中使用WebDriverJs启动Internet Explorer - Cannot launch Internet Explorer with WebDriverJs in Selenium Selenium 自动化通过apptool应用启动Internet Explorer - Selenium automation Launching internet explorer throughapptool app Selenium Building Internet Explorer驱动程序JavaScript错误 - Selenium building internet explorer driver javascript error Selenium - 等待 ScrollIntoView 完成 - Selenium - Wait for the ScrollIntoView to finish 在 Internet Explorer 中使用 selenium 的 JavascriptExecutor 打开一个新选项卡 - Open a new tab using JavascriptExecutor of selenium in Internet Explorer C#Selenium Webdriver在Internet Explorer中捕获javascript错误 - C# Selenium webdriver Catch javascript errors in Internet explorer IE驱动程序无法使用Internet Explorer驱动程序配置在JMeter中使用Selenium - IE driver is not working with Selenium in JMeter using Internet explorer driver config 使用 Python 和 Selenium 在 Internet Explorer 11 中自动下载文件 - Download files automatically in Internet Explorer 11 with Python and Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM