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

Selenium setting window size is inaccurate, finally solved

PHPz
PHPzOriginal
2017-03-18 17:35:412394browse

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}

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
)


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!

Statement:
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