Webdriver Action Tab

Source: Internet
Author: User

Core idea: Use the keyboard shortcuts in Firefox or other browsers and then work with the action.

Firefox shortcut key: https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly


The following is a code example:

package webdriver;import java.util.logging.logger;import org.openqa.selenium.keys;import  org.openqa.selenium.webdriver;import org.openqa.selenium.firefox.firefoxdriver;import  org.openqa.selenium.interactions.actions;import org.testng.annotations.afterclass;import  org.testng.annotations.beforeclass;import org.testng.annotations.test;public class  Testwebdriver {private static final logger logger = logger.getlogger ( TestWebDriver.class.getName ());p rivate webdriver webdriver; @BeforeClasspublic  void  Beforeclass () {webdriver = new firefoxdriver ();} @Testpublic  void f () {webdriver.get ("http://www.sohu.com"); String title = webdriver.gettitle (); Actions actions = new actions (Webdriver);//open a new tabactions.keydown ( Keys.control). SendKeys ("T"). KeyUp (Keys.control). Perform ();//change to the second wIndowwhile (True) {Actions.keydown (Keys.control). SendKeys (Keys.tab). KeyUp (Keys.control). Perform (); Logger.info ( Webdriver.gettitle ()); if (!title.equals (Webdriver.gettitle ())) {Break;}}} @AfterClasspublic  void afterclass () {webdriver.quit ();}}


Webdriver Action Tab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.