当前位置:网站首页>Katalon框架测试一个web页面操作实例代码
Katalon框架测试一个web页面操作实例代码
2022-06-28 10:19:00 【春天的菠菜】
页面操作元素就没有发出来,这里主要是为自己学习当中做经验沉淀
目录
一、源码
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('')
'这里使用了全局变量'
WebUI.navigateToUrl(GlobalVariable.url)
'最大化'
WebUI.maximizeWindow()
'输入账号,这里使用了全局变量'
WebUI.setText(findTestObject('Object Repository/login/input_username'), GlobalVariable.username)
'输入密码,这里使用了局部变量'
WebUI.setText(findTestObject('login/input_password'), password)
'点击登录按钮'
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'), '监控')
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'), '部门')
'保存'
WebUI.click(findTestObject('maintain/deptmanger/button_add_dept_page_save'))
WebUI.verifyElementText(findTestObject('maintain/deptmanger/span_msg'), '添加成功')
WebUI.delay(2)
'定义一个对象类'
WebElement element = WebUI.findWebElement(findTestObject('maintain/deptmanger/span_tree_add_dept'), 30)
WebUI.executeJavaScript('arguments[0].click();', Arrays.asList(element))
'点击修改按钮'
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'), '修改成功')
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'), '删除成功')
WebUI.closeBrowser()
二、重点说明
1、使用JS操作页面点击不到的元素
引用
import org.openqa.selenium.WebElement as WebElement主要为了,原因是点击不到元素对象,适应JS去点击
'定义一个对象类(查找新增的部门,在树上的位置)'
WebElement element = WebUI.findWebElement(findTestObject('maintain/deptmanger/span_tree_add_dept'), 30)
'选中新增的树上的部门'
WebUI.executeJavaScript('arguments[0].click();', Arrays.asList(element))2、鼠标悬停
'鼠标移动到计量管控系统的系统切换icon位置'
WebUI.mouseOver(findTestObject('maintain/deptmanger/link_system_menu'), FailureHandling.STOP_ON_FAILURE)边栏推荐
- 第五章 树和二叉树
- [unity][ecs] learning notes (III)
- Correct conversion between JSON data and list collection
- Six fusion positioning technologies in wireless communication application of Internet of things
- SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
- Read PDF image and identify content
- Hystrix 部署
- 使用 ABAP 操作 Excel 的几种方法
- 丢弃 Tkinter!简单配置快速生成超酷炫 GUI!
- 【力扣——动态规划】整理题目1:基础题目:509、70、746、62、63、343、96(附链接、题目描述、解题方法及代码)
猜你喜欢

How to view the web password saved by Google browser

Caffeine cache, the king of cache, has stronger performance than guava

Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"

港伦敦金行情走势图所隐藏的信息

Fastposter v2.8.4 release e-commerce poster generator

Unity AssetBundle asset packaging and asset loading

如何使用 DataAnt 监控 Apache APISIX
![[Unity]内置渲染管线转URP](/img/a5/3ae37b847042ffb34e436720f61d17.png)
[Unity]内置渲染管线转URP

学习机器学习的最佳路径是什么

sqlcmd 连接数据库报错
随机推荐
我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!
Cisco * VRF(虚拟路由转发表)
Who knows if it is safe to open an account with CSC securities
The introduction of flink-sql-mysql-cdc-2.2.1 has solved many dependency conflicts?
学习机器学习的最佳路径是什么
物联网无线通信应用中6种融合定位技术
As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it
无线通信模块定点传输-点对多点的具体传输应用
关于FTP的协议了解
Teach you how to handle the reverse SVG mapping of JS
无线模块透明传输技术的物联网应用案例
栈的弹出压入序列<难度系数>
[unity] built in rendering pipeline to URP
Solve the problem that the value of the action attribute of the form is null when transferring parameters
bye! IE browser, this route edge continues to go on for IE
Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
fastposter v2.8.4 发布 电商海报生成器
Read PDF image and identify content
Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface
Pop up and push in sequence of stack < difficulty coefficient >