Home > Article > WeChat Applet > Selenium setting window size is inaccurate, finally solved
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!