当前位置:网站首页>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)边栏推荐
- 手把手教你处理 JS 逆向之 SVG 映射
- Chapter 5 trees and binary trees
- [unity][ecs] learning notes (I)
- R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
- Read PDF Text and write excel operation
- 六月集训(第28天) —— 动态规划
- Fabric.js 笔刷到底怎么用?
- Training and recognition of handwritten digits through the lenet-5 network built by pytorch
- Chapter 3 stack and queue
- 解析:去中心化托管解决方案概述
猜你喜欢

DlhSoft Kanban Library for WPF

Wireless communication module fixed-point transmission - point to multipoint specific transmission application

我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!

dotnet 使用 Crossgen2 对 DLL 进行 ReadyToRun 提升启动性能

使用 ABAP 操作 Excel 的几种方法

Solve the problem that the value of the action attribute of the form is null when transferring parameters

手把手教你处理 JS 逆向之 SVG 映射

无线通信模块定点传输-点对多点的具体传输应用

linux中源码安装mysql数据库(centos)

An error is reported when uninstalling Oracle
随机推荐
Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface
如何利用k线图做技术分析
无线模块透明传输技术的物联网应用案例
What is the difference between MySQL development environment and test environment??
Unity loads AssetBundle resources from the server and writes them to local memory, and loads the downloaded and saved AB resources from local memory to the scene
fastposter v2.8.4 发布 电商海报生成器
在OpenCloudOS使用snap安装.NET 6
增量快照 必须要求mysql表有主键的吗?
我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!
Training and recognition of handwritten digits through the lenet-5 network built by pytorch
Wireless communication module fixed-point transmission - point to multipoint specific transmission application
[Unity][ECS]学习笔记(一)
增强 Jupyter Notebook 的功能,这里有四个妙招
Google开源依赖注入框架-Guice指南
Discard Tkinter! Simple configuration to quickly generate cool GUI!
Chapter 5 trees and binary trees
Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
关于FTP的协议了解
学习机器学习的最佳路径是什么
【功能建议】多个工作空间启动时选择某个空间