SELENIUM2 Learning -020-webui Automated Combat instance -018-Get browser window position size

Source: Internet
Author: User

In the UI Automation testing process, the default size of the browser on each machine, the default location is not the same, when required, the page element may not be displayed completely, so we need to know the width of the browser, or directly in the browser when the browser, set the width or location of the Web (this article is not covered, the subsequent article updates, thank you)

Directly on the code:

1     /**2 * Get position and size of browser3      * 4      * @authorAARON.FFP5      * @versionV1.0.0:autoseleniumdemo main.aaron.sele.core Seleniumcore.java getbrowsersize, 2015-7-28 01:12:04 Exp $6      * 7      * @returnInt[left|top|width|height]8      */9      Public int[] Getbrowserpositionandsize () {Ten         int[] Posandsize =New int[2]; One          A         //Get Browser position -Point Browser_pos = This. Webdriver.manage (). window (). getPosition (); -          thePosandsize[0] =browser_pos.getx (); -POSANDSIZE[1] =browser_pos.gety (); -          -         //Get Browser size +Dimension browser_size = This. Webdriver.manage (). window (). GetSize (); -          +POSANDSIZE[2] =Browser_size.width; APOSANDSIZE[3] =Browser_size.height; at          -         returnposandsize; -}

At this point, theWebUI automation function test Script No. 018-Get the browser window size Smooth end, I hope this article can give beginners Selenium you a reference.

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 -020-webui Automated Combat instance -018-Get browser window position size

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.