当前位置:网站首页>Katalon framework tests a web page operation example code
Katalon framework tests a web page operation example code
2022-06-28 10:36:00 【Spinach in spring】
Page operation elements are not sent out , Here is mainly for their own learning experience precipitation
Catalog
1、 Use JS Elements that cannot be clicked on the operation page
One 、 Source code
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import com.kms.katalon.core.annotation.Keyword as Keyword
import org.openqa.selenium.WebElement as WebElement
WebUI.openBrowser('')
' Here we use global variables '
WebUI.navigateToUrl(GlobalVariable.url)
' Maximize '
WebUI.maximizeWindow()
' Enter account , Here we use global variables '
WebUI.setText(findTestObject('Object Repository/login/input_username'), GlobalVariable.username)
' Input password , Local variables are used here '
WebUI.setText(findTestObject('login/input_password'), password)
' Click the login button '
WebUI.click(findTestObject('Object Repository/login/button_login'))
WebUI.click(findTestObject('Object Repository/maintain/deptmanger/img_select_meter_system'))
WebUI.delay(2)
WebUI.getText(findTestObject('meter/home/span_meter_home_text'))
WebUI.verifyElementText(findTestObject('meter/home/span_meter_home_text'), ' monitor ')
WebUI.mouseOver(findTestObject('maintain/deptmanger/link_system_menu'), FailureHandling.STOP_ON_FAILURE)
WebUI.click(findTestObject('maintain/deptmanger/link_chang_menu_level_maintain'))
WebUI.click(findTestObject('maintain/deptmanger/button_add_dept'))
WebUI.setText(findTestObject('maintain/deptmanger/input__add_dept_page_name'), ' department ')
' preservation '
WebUI.click(findTestObject('maintain/deptmanger/button_add_dept_page_save'))
WebUI.verifyElementText(findTestObject('maintain/deptmanger/span_msg'), ' Add success ')
WebUI.delay(2)
' Define an object class '
WebElement element = WebUI.findWebElement(findTestObject('maintain/deptmanger/span_tree_add_dept'), 30)
WebUI.executeJavaScript('arguments[0].click();', Arrays.asList(element))
' Click the Modify button '
WebUI.click(findTestObject('maintain/deptmanger/button_alter_dept'))
WebUI.setText(findTestObject('maintain/deptmanger/input_dept_principal'), 'superman')
WebUI.click(findTestObject('maintain/deptmanger/button_alter_dept'))
WebUI.verifyElementText(findTestObject('maintain/deptmanger/span_msg'), ' Modification successful ')
WebUI.click(findTestObject('maintain/deptmanger/button_delete_dept'))
WebUI.delay(3)
WebUI.click(findTestObject('maintain/deptmanger/button_confirm'))
WebUI.verifyElementText(findTestObject('maintain/deptmanger/span_msg'), ' Delete successful ')
WebUI.closeBrowser()
Two 、 Key points
1、 Use JS Elements that cannot be clicked on the operation page
quote
import org.openqa.selenium.WebElement as WebElementMainly for , The reason is that the element object cannot be clicked , To adapt to JS To click on
' Define an object class ( Find the new Department , Position on the tree )'
WebElement element = WebUI.findWebElement(findTestObject('maintain/deptmanger/span_tree_add_dept'), 30)
' Select the Department in the new tree '
WebUI.executeJavaScript('arguments[0].click();', Arrays.asList(element))2、 Mouse hovering
' Move the mouse to the system switch of the measurement control system icon Location '
WebUI.mouseOver(findTestObject('maintain/deptmanger/link_system_menu'), FailureHandling.STOP_ON_FAILURE)边栏推荐
- 移动命令
- 【monkey】monkey测试入门
- DlhSoft Kanban Library for WPF
- Discard Tkinter! Simple configuration to quickly generate cool GUI!
- 第五章 树和二叉树
- Teach you how to handle the reverse SVG mapping of JS
- To enhance the function of jupyter notebook, here are four tips
- idea连接sql sever失败
- Idea failed to connect to SQL Sever
- 2D code generator for openharmony application development
猜你喜欢

第六天 脚本与动画系统

Wireless communication module fixed-point transmission - point to multipoint specific transmission application
![[unity][ecs] learning notes (I)](/img/eb/1f0ad817bbc441fd8c14d046b82dd0.png)
[unity][ecs] learning notes (I)

如何使用 DataAnt 监控 Apache APISIX

Realization of a springboard machine

使用 ABAP 操作 Excel 的几种方法

接口自动化框架脚手架-参数化工具的实现

Realization of a springboard machine

fastposter v2.8.4 发布 电商海报生成器

Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
随机推荐
Who knows if it is safe to open an account with CSC securities
Ribbon核心源码解析
Wireless communication module fixed-point transmission - point to multipoint specific transmission application
[unity] built in rendering pipeline to URP
Internet of things application case of wireless module transparent transmission technology
Fabric.js 笔刷到底怎么用?
MySQL查看数据库性能常用命令
一种跳板机的实现思路
fastposter v2.8.4 发布 电商海报生成器
物联网无线通信应用中6种融合定位技术
What is the best way to learn machine learning
Realization of a springboard machine
使用 ABAP 操作 Excel 的几种方法
【NLP】今年高考英语AI得分134,复旦武大校友这项研究有点意思
The R language uses the avplots function in the car package to create added variable plots. In image interaction, manually identify (add) strong influence points that have a great impact on each predi
appliedzkp zkevm(10)中的Transactions Proof
What is the difference between MySQL development environment and test environment??
第六天 脚本与动画系统
ruoyi集成积木报表(nice)
As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it