Selenium+java First Demo

Source: Internet
Author: User

Finally, start writing for the first time ~

Let's have a simple one ~

  

 PackageSelenium;Importorg.openqa.selenium.Dimension;ImportOrg.openqa.selenium.WebDriver;ImportOrg.openqa.selenium.firefox.FirefoxDriver; Public classSeleniumjava { Public Static voidMain (string[] args) {Dimension Dimension; //declare variables for use belowDimension drsize =NewDimension (850,1280);//Create an instance and assign a value (350,600)//system.setproperty ("Webdriver. Firefox.driver "," C://Firefox//Firefox.exe ");
     //if the browser is not the default path installation, you need to specify a pathWebdriver Dr =NewFirefoxdriver ();//Open Firefox BrowserDr.manage (). window (). setSize (Drsize);//set the form size to DrsizeDr.manage (). window (). Maximize ();//Maximize Your browserDr.get ("http://www.baidu.com");//Open Web pageDimension = Dr.manage (). window (). GetSize ();//Get Browser sizeSystem.out.print ("Browser current height is" +dimension.getheight () + "; Browser current width is" +dimension.getwidth ());
//output Browser height and widthDr.close (); }}
The Dimension class, which encapsulates the height and width of a component.
Dr.manage (). window (). setSize (Drsize); Set the form size.
Dr.manage (). window (). Maximize ();      Set the form to maximized.
Dr.manage (). window (). GetSize ();       Gets the form size, has a return value, and needs to be copied to the variable.


Selenium+java First Demo

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.