Web Automation Test

CukeTest provides a complete Web automation test. It provides the function of automatically generating Web automation scripts. The function of recording and replaying Web operations.

Recording Web Testing

CukeTest provides the built-in Web recording and playback function to help test developers generate automated scripts by recording web operations. These scripts can be run directly or directly integrated into existing projects as business logic operation procedures. To use. Currently, recording on Chrome (85 and above) is supported, and more types of browsers can be used for playback. This function is based on the PlayWright framework, and the detailed API can be found in the PlayWright documentation.

Create a project using a web template

CukeTest provides a Web project template, which contains simple examples, which can be run directly or added to code execution after recording. In fact, web recording can be performed in any project, and a new JavaScript file will be generated during the recording process, which can be played back directly. Here are the steps to create a project using the web recording template:

Start recording

  1. Click "New Project"
  2. Select "Web" in the template drop-down box in the project configuration dialog box
  3. Click! "Record Web" button in the toolbar

It can be observed that the browser is started and the address bar is empty. Just enter the address of the website to be recorded to start the recording operation.

Specify URL recording

  1. Click "New Project"
  2. Select "Web" in the template drop-down box in the project configuration dialog box
  3. Click the drop-down button in the lower right corner of the "Web Recording" button, click "Recording Configuration", and enter the website address to be recorded in the "Start URL" item in the pop-up panel "Recording Settings" button
  4. Click the "Start Recording" button

It can be observed that the browser is started, the address bar is the website address specified in the configuration, and the recording operation can be started directly.

Using Web Recording Function

In the above steps, a simple web recording project template was created, which can be modified directly on the basis of the template, or you can click! "Record Web" button to start recording a new Web automation script. You can select "Recording Settings" from the drop-down list next to the "Record Web" button to open the dialog box and modify the default startup URL.

Recording settings

In the "Recording Settings" dialog box, in addition to modifying the default URL, there are the following settings:

  • Browser: Select the browser used for recording. Currently, Chrome and Firefox browsers are supported for recording. After recording, you can modify the recorded code to use other browsers, such as Edge and other browsers;
  • Start URL: the default URL visited when recording starts;
  • Recording parameters: The startup parameters that will be passed to the browser when the recording is started. For example, the viewport-size parameter can specify the window size. The default value is 1280,720, which means that the content is only displayed in the range of 1280x720, and the content is out of range. The content needs to move the scroll bar to view. See the table below for the explanation of options and parameters. When specifying the value of an option, you do not need to quote it.
选项名 参数名 选项解释
color-scheme 主题颜色 模拟首选配色方案,“light”或“dark”
geolocation 地理定位 指定地理位置坐标,例如“37.819722,-122.478611”
lang 语言/区域 指定语言/区域设置,例如“zh-CN”
proxy-server 代理服务器 指定代理服务器,例如“http://myproxy:3128”或“socks5://myproxy:8080”
timezone 时区 要模拟的时区,例如“Europe/Rome”
timeout 超时时间 动作的超时时间(以毫秒为单位)(默认值:“20000”)
viewport-size 视窗大小 以像素为单位指定浏览器视窗大小,例如“1280, 720”
user-agent 用户代理 指定用户代理字符串
option arg desc
color-scheme <scheme> emulate preferred color scheme, "light" or "dark"
geolocation <coordinates> specify geolocation coordinates, for example "37.819722,-122.478611"
lang <language> specify language / locale, for example "en-GB"
proxy-server <proxy> specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"
timezone <time zone> time zone to emulate, for example "Europe/Rome"
timeout <timeout> timeout for Playwright actions in milliseconds (default: "10000")
user-agent <ua string> specify user agent string
viewport-size <size> specify browser viewport size in pixels, for example "1280, 720"
  • Ask to save the file name before recording: When it is not selected, a script file with the default file name will be automatically generated for each recording; after it is selected, the user will be asked for the file name of the script saved before each recording;

Recording process

After recording starts, all operations in the opened window will generate corresponding scripts and write them into the script file. The generated scripts are also relatively simple. If you have the basis of Web automation, you can quickly understand the role of each script. If you need to further understand the meaning of the script, you can check the official PlayWright documentation. During the recording process, it is invalid for the user to modify the script file being recorded, because the recording engine will modify the script according to the operation on the browser, which will overwrite the user's modification, so please stop the recording before modifying the recorded script code.

Playback process

After the recording is complete, you can click "Run Script" button in the toolbar to start playback of the recorded operation. If there is no such button, you need to click"Switch View" button Switch to Script view only.

If the recorded script needs to be adjusted, because the script generated by the recording uses the operation API of Playwright, you can refer to PlayWright's API document Adjustment. For a video introduction to the recording operation, you can watch the relevant content in Introduction Video.

Develop Web Automation Scripts by Other Frameworks

In addition to the built-in web recording and playback library, CukeTest can also support users to use other open source frameworks, such as Selenium, Puppeteer, etc.

Most web automation frameworks provide JavaScript implementations. For example, Selenium provides Selenium-WebDriver for writing JavaScript scripts.

CukeTest also has built-in support for the Selenium-WebDriver framework, including the creation of Selenium-Web project templates and API smart prompts, as well as Web Automation Demo Project samples and instructions .

Chinese version click here.

results matching ""

    No results matching ""