Home > WeChat Applet > WeChat Development > Selenium setting window size is inaccurate, finally solved

Selenium setting window size is inaccurate, finally solved

PHPz
Release: 2017-03-18 17:35:41
Original
2419 people have browsed it

The window size set by selenium is not accurate, and an error occurs during functional testing. It turns out that this is the reason. Let’s summarize!

from selenium import webdriver
self.browser = webdriver.Firefox()
self.browser.set_window_size(1024, 768)
self.browser.get_window_size()    
    {u'height': 638, 'value': None, u'width': 1229}
Copy after login

This is how it passed during the test:

inputbox = self.browser.find_element_by_id('id_new_item')
self.assertAlmostEqual(
    inputbox.location['x'] + inputbox.size['width']/2,
    # 512,
    self.browser.get_window_size().get("width")/2,
    delta=5
)
Copy after login


The above is the detailed content of Selenium setting window size is inaccurate, finally solved. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template