课程: Selenium Essential Training
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Executing JavaScript commands
- [Instructor] JavaScript commands can sometimes be necessary in WebDriver tests. Luckily, Selenium supports the JavascriptExecutor. The JavascriptExecutor provides two methods to run JavaScript on the selected window or current page. First is the executeAsyncScript method. This executes an asynchronous piece of JavaScript, and scripts executed with this method must explicitly signal they are finished by invoking the provided callback. There is also the executeScript method. In this method executes JavaScript as the body of an anonymous function. There are a few use cases for using the JavascriptExecutor. First, I've used it when Selenium WebDriver fails to click on any element due to some issue. It can also generate alerts and run other scripts to trigger actions on a page. And third, it can manipulate the page and perform actions like scrolling and zooming. So, in this video, I'll demonstrate a simple example of using the JavascriptExecutor to click on an element within a modal that…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。