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!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PyCharm installation tutorial: Easily learn how to install Selenium, specific code examples are needed. As Python developers, we often need to use various third-party libraries and tools to complete project development. Among them, Selenium is a very commonly used library for automated testing and UI testing of web applications. As an integrated development environment (IDE) for Python development, PyCharm provides us with a convenient and fast way to develop Python code, so how

Laravel development: How to use LaravelDusk and Selenium for browser testing? As web applications become more complex, we need to ensure that all parts of it function properly. Browser testing is a common testing method used to ensure the correctness and stability of an application under various browsers. In Laravel development, you can use LaravelDusk and Selenium for browser testing. This article will introduce how to use these two tools to test

Overview of How to Use Selenium for Web Automation Testing: Web automation testing is a vital part of the modern software development process. Selenium is a powerful automated testing tool that can simulate user operations in a web browser and implement automated testing processes. This article will introduce how to use Selenium for web automation testing, and come with code examples to help readers get started quickly. Environment preparation Before starting, you need to install the Selenium library and web browser driver

Using Selenium and PhantomJS in Scrapy crawlers Scrapy is an excellent web crawler framework under Python and has been widely used in data collection and processing in various fields. In the implementation of the crawler, sometimes it is necessary to simulate browser operations to obtain the content presented by certain websites. In this case, Selenium and PhantomJS are needed. Selenium simulates human operations on the browser, allowing us to automate web application testing

With the rapid development of Internet technology, Web applications are increasingly used in our daily work and life. In the process of web application development, crawling web page data is a very important task. Although there are many web scraping tools on the market, these tools are not very efficient. In order to improve the efficiency of web page data crawling, we can use the combination of PHP and Selenium. First, we need to understand what PHP and Selenium are. PHP is a powerful

Steps to install selenium with pycharm: 1. Open PyCharm; 2. Select "File", "Settings", "Project: [Project Name]" in the menu bar; 3. Select Project Interpreter; 4. Click on the right side of the tab "+"; 5. Search for selenium in the pop-up window; 6. Find selenium and click the "Install" button next to it; 7. Wait for the installation to complete; 8. Close the settings dialog box.

1. Slider verification idea The slider object of the object under test looks like this. Relatively speaking, it is a relatively simple form. You need to drag the puzzle on the left through the slider below and embed it into the empty slot on the right to complete the verification. To automate this verification process, the key point is to determine the distance the slider slides. According to the above analysis, the key point of verification is to determine the sliding distance of the slider. But a seemingly simple requirement is not simple to complete. If you use natural logic to analyze this process, it can be broken down as follows: 1. Locate the position of the puzzle on the left. Since the shape and size of the puzzle are fixed, you only need to locate the distance between its left border and the left side of the background image. (Actually, in this example, the starting position of the puzzle is also fixed, saving

With the development of the Internet, network data crawling has increasingly become the focus of attention. Web data crawlers can collect a large amount of useful data from the Internet to support enterprises, academic research, and personal analysis. This article will introduce the methods and steps for building a web data crawler using PHP and Selenium. 1. What is a web data crawler? Web data crawlers refer to automated programs that collect data from designated websites on the Internet. Web data crawlers are implemented using different technologies and tools, the most common of which are using programming languages ??and
