当前位置:网站首页>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)边栏推荐
- Fastposter v2.8.4 release e-commerce poster generator
- 移动命令
- metersphere使用js刷新当前页面
- 【实操】Appium Settings app is not running after 5000ms
- [unity][ecs] learning notes (II)
- Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
- MySQL general binary installation method
- idea连接sql sever失败
- 工控安全之勒索病毒篇
- DlhSoft Kanban Library for WPF
猜你喜欢

增强 Jupyter Notebook 的功能,这里有四个妙招

To enhance the function of jupyter notebook, here are four tips

Katalon当中的debug调试

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

一文读懂 12种卷积方法(含1x1卷积、转置卷积和深度可分离卷积等)
![[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)](/img/02/4dbd97c8b8df1c96b7c8e1460aeda2.png)
[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)
![[Unity][ECS]学习笔记(一)](/img/eb/1f0ad817bbc441fd8c14d046b82dd0.png)
[Unity][ECS]学习笔记(一)

Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
![[Unity]内置渲染管线转URP](/img/a5/3ae37b847042ffb34e436720f61d17.png)
[Unity]内置渲染管线转URP

Day 6 script and animation system
随机推荐
Solve the problem that the value of the action attribute of the form is null when transferring parameters
一文读懂 12种卷积方法(含1x1卷积、转置卷积和深度可分离卷积等)
datetime与logging模块
如何使用 DataAnt 监控 Apache APISIX
一种跳板机的实现思路
Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
DlhSoft Kanban Library for WPF
R language plot visualization: plot to visualize overlapping histograms, and use geom at the bottom edge of the histogram_ The rugfunction adds marginal rugplots
各位大佬,问下Mysql不支持EARLIEST_OFFSET模式吗?Unsupported star
解析:去中心化托管解决方案概述
2022吴恩达机器学习specialization Week 2 practice lab: Linear regression
Read PDF image and identify content
错过金三银四,找工作4个月,面试15家,终于拿到3个offer,定级P7+
[unity][ecs] learning notes (III)
第六天 脚本与动画系统
线程和线程池
Interface automation framework scaffolding - Implementation of parametric tools
Ruoyi integrated building block report (NICE)
How to use K-line diagram for technical analysis
[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)