课程: Test Automation with Selenium WebDriver for Java

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Double-click

Double-click

- [Instructor] Double clicking is typically used to trigger specific actions or features on a web page. For example, if we double click this input field, we see the text "double-clicked" appear. Let's write a script that double clicks this input element and prints the text. Let's find the input element by its ID. So we can say: var input = driver.findElement(By.id), and it's ID is "clickable". Then we can use the Actions class to call the DoubleClick() method. So we'll say: new Actions, passing our driver, and then call DoubleClick(). Inside of the DoubleClick() method, we can pass in the element that we want it to double click on. And then we'll also need to call Perform() in order to execute this action. Now, let's print out the status. So we'll say: print driver.findElement(By.id), and that text field's element was "click-status", and then we want to call .getText(). Okay, let's run it. Perfect, we see that it did in fact double click the input element, and it obtained the text…

内容