Selenium Test (Java)--keyboard events (vii)

Source: Internet
Author: User
Tags xpath

 1 package Com.test.key; 2 3 Import Org.openqa.selenium.By; 4 Import Org.openqa.selenium.Keys; 5 Import Org.openqa.selenium.WebDriver; 6 Import Org.openqa.selenium.firefox.FirefoxDriver; 7 8 public class KeyB {9, public static void main (string[] args) {One webdriver driver = new Firefoxdriver ( ); Driver.get ("http://www.baidu.com"); Driver.manage (). window (). Maximize (); 14 15//Input Box         Input content: Driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys ("Selenium"); 17 18//Delete a M19 Driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys (Keys.back_space); 20 21//Enter M space tutorial in driver . Findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys ("M"); Driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys         (Keys.space), Driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys ("tutorial"); 25 26//Select all input Box Contents 27   Driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys (Keys.control, "a"); 28      29//Cut input Box Contents driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys (Keys.control, "X"); 31 3         2//Paste input box content driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys (Keys.control, "V"); 34 35 Replace the commit action by a carriage return of driver.findelement (By.xpath ("//*[@id = ' kw ')"). SendKeys (Keys.enter); PNs Waitti             Me (driver.quit);}41-static public void waitTime (int time) {45              Thread.Sleep (time); Interruptedexception} catch (e) {//TODO auto-generated catch block48 E.printstacktrace (); 49}50}51 52}

Selenium Test (Java)--keyboard events (vii)

Related Article

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.