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