SELENIUM2 Learning -023-webui Automation actual combat instance -021-get the browser display area size, through the Webdriver screenshot function

Source: Internet
Author: User

Previous blog post 020-javascript application example in Selenium automation (get browser display area size) A brief description of the size of the browser display area via JavaScript, this article will briefly describe another way to get the size of the browser display area, by Webdriver functions, gets the size of the display area, by the size of the browser display area.

Directly on the code, please see the small owners, if there are shortcomings, please the great God, I appreciate it!

1     /**2 * Get width and height about display screens area by Takesscreenshot image size3      * 4      * @authorAARON.FFP5      * @versionV1.0.0:autoseleniumdemo main.aaron.sele.core Seleniumcore.java getbrowserdisplayareasize, 2015-7-28 02:15:01 Exp $6      * 7      * @returnInt[width,height]8      */9      Public int[] Getbrowserdisplayareasize () {Ten         int[] WH =New int[2]; One          A         Try { -             //Get Byte data of full screen capture -             byte[] Byte_screen_capture = ((takesscreenshot) This. Webdriver). Getscreenshotas (outputtype.bytes); the              -             //Create Full screen cpature -BufferedImage img_screen_catpture = Imageio.read (NewBytearrayinputstream (byte_screen_capture)); -              +Wh[0] =img_screen_catpture.getwidth (); -WH[1] =img_screen_catpture.getheight (); +              AImg_screen_catpture =NULL; atByte_screen_capture =NULL; -}Catch(Exception e) { - e.printstacktrace (); -         } -          -         returnWH; in}

At this point, theWebUI automation function test script section 020-javascript in the Selenium Automation application instance of the second (get browser display area size) successfully completed, I hope this article can give beginners Selenium A reference for you.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

SELENIUM2 Learning -023-webui Automation actual combat instance -021-get the browser display area size, through the Webdriver function

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.