Java+selenium "ENTRY" that mimics the keyboard after entering content into the text box

Source: Internet
Author: User

In automated testing we can not avoid to imitate some keyboard buttons on the operation, ordinary letters, numbers, special symbols, these are very simple, and sometimes we will imitate "SHIFT", "ALT", "CONTROL", these selenium has provided the action, Specific as follows:

        New Actions (driver);        Actions.keydown (Keys.control); // Press to release control         Actions.keydown (keys.control);        Actions.keydown (keys.shift); // Press to release shift         Actions.keydown (keys.shift);        Actions.keydown (Keys.alt); // Press to release Alt         Actions.keydown (keys.alt);        Actions.keydown (keys.tab); // Press to release tab        Actions.keydown (Keys.tab);

But when we enter some text in the text box, or do some other action, and then click on Entey execution, it will not work as above, because selenium does not provide this kind of operation, specifically.

The solution is as follows:

Driver.findelement (by.id ("name")). SendKeys ("* * *");d river.findelement (by.id ("name")). SendKeys (" Keys.enter ");

Java+selenium "ENTRY" that mimics the keyboard after entering content into the text box

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.