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