课程: Test Automation with Selenium WebDriver for Java

免费学习该课程!

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

Context click

Context click

- [Instructor] Context clicking often referred to as right clicking is used to open a context menu which provides additional options. For example, by right clicking on this input element, I've triggered its context menu to appear. And I've also triggered this text, "Context-clicked" to appear. Let's use Selenium WebDriver to perform a context click. We can find the element that we want to right click on. So let's save our input equals driver.findElement by ID and its ID is clickable. Then we can use the actions class to call context click, and then we'll call the perform to trigger this action. So we'll say new actions, passing the driver.contextClick and we want to pass in our elements and then call perform. And finally, let's print the status message to make sure the action was performed. So we'll say driver.findElement by id and its ID is click-status and we want to get the text. Okay, let's run it. Great, we see that it's successfully performed a context click.

内容