Selenium is a web automation testing framework that supports a variety of browsers, including Chrome, Safari, Firefox, and other major browsers.

Thanks to Selenium’s good support for Python, the Airtest-Selenium plugin was added to the Airtest Project. AirtestIDE can be used for web automation script recording, running and report generation.
This article describes how to use AirtestIDE for web automation testing using Chrome driver.

Please note that this article is above 1,000 words. It may take up to 4 minutes to read it fully

When the user wants to generate a single code statement separately, the button of the auxiliary window can be used to help generate the desired operation. The buttons are divided into two categories which functions are described in detail below.

After clicking this type of buttons, the code will not be generated directly; the browser will first enter the inspect mode, where the desired element can be selected. Then, the code will be generated in the edit box to perform the indicated function in the located element.

Inspect button: When clicking this button and selecting the page element, a statement selecting that element is generated. However, no operation code is generated here, the user should indicate which selenium statement to execute after the selection. Example:
driver.find_element_by_xpath("//*[@id=\"navbarContent\"]/ul/li[2]/a")

touch button: When clicked, it generates code to click the selected element. Example:
driver.find_element_by_xpath("//*[@id=\"navbarContent\"]/ul/li[2]/a").click()
Note that the first part of the statement is the same for inspect button: the selection of the element.

text button: Clicking this button generates a statement for entering text in the selected element. After generating the code, the text parameter must be filled in. At the same time, a keyboard event can be defined, such as a carriage return, that will be performed after typing. Example:
driver.find_element_by_xpath("//input[@placeholder='Search']").send_keys("AirtestProject",Keys.ENTER)

assert button: The assert button, when clicked, generates a statement that asserts if the element exists in the page at runtime. This is an Airtest-Selenium packaged statement. It returns ‘True’ if the element is found, and ‘False’ if it is not found. Can be used to test whether the script was successful. Example:
driver.assert_exist("//*[@id=\"js-pjax-container\"]/div/header/div/nav/a[2]","xpath")

After clicking this type of buttons, code will be generated directly; No extra operations are required, but some buttons generate different parameters based on the current browser.

start_web: Click this button to generate a statement to set the page address on the current browser. Example:
driver.get("https://github.com/AirtestProject")

snapshot: Click this button to generate a statement that takes a screenshot of the current page. Example:
driver.snapshot()

new_tab: Click this button to generate a statement that jumps to the most recently opened tab. This is usually used after a statement that generates a new tab. Example: driver.switch_to_latest_window()

previous_tab: Click this button to generate a statement that jumps to the tab that was accessed before moving to the current tab (parent tab). Example: driver.switch_to_last_window()

back: Click this button to generate a statement that goes back to the previous page. Example: driver.back()

forward: Click this button to generate a statement that advances to the next page. Example:driver.forward()

Explanation:
The browser is originally on the first tab page (A).
After the first sentence runs, another tab page is generated (B). Since the browser’s behaviour is to jump to the new tab, most use cases would need to operate on this newly opened B tab.
In order to tell the web driver to load the B’s dom tree structure instead of A’s, the driver.switch_to_latest_window() statement is required.

Use driver.switch_to_last_window() statement to go back to the tab prior to the driver.switch_to_latest_window execution.
In the example above, after the operation on the B tab page is completed, use driver.switch_to_last_window() in order to tell the web driver to load the A’s dom tree structure again instead of B’s.
The next line of script will be executed on the A tab.

In the recording mode, when the user generates a new tab through an operation, Airtest-Selenium recognizes the change of the tab and switches to the latest tab, generating the corresponding code in the edit box.
Click on ‘Close tab’ and Airtest-Selenium will jump back to the previous tab, generating the code to close and recall the tab in the edit box.