当前位置:网站首页>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)边栏推荐
- Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface
- datetime与logging模块
- MySQL cannot be opened. Flash back
- 【功能建议】多个工作空间启动时选择某个空间
- Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
- 物联网无线通信应用中6种融合定位技术
- I'm almost addicted to it. I can't sleep! Let a bug fuck me twice!
- An error is reported when uninstalling Oracle
- 错过金三银四,找工作4个月,面试15家,终于拿到3个offer,定级P7+
- [200 opencv routines] 213 Draw circle
猜你喜欢

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

如何利用k线图做技术分析

解析:去中心化托管解决方案概述

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

Set up your own website (11)

Mysql database overview and installation process

The boss asked me to write an app automation -- yaml file reading -- with the whole framework source code attached

How does ETF position affect spot gold price?

线程和线程池

Teach you how to handle the reverse SVG mapping of JS
随机推荐
Dear leaders, ask me if MySQL does not support early_ Offset mode? Unsupported star
Interface automation framework scaffolding - Implementation of parametric tools
[Unity][ECS]学习笔记(一)
Internet of things application case of wireless module transparent transmission technology
Generate token
解析:去中心化托管解决方案概述
【实操】Appium Settings app is not running after 5000ms
ECS MySQL query is slow
Katalon当中的output使用方法
物联网无线通信应用中6种融合定位技术
[leetcode daily question] [December 19, 2021] 997 Find the town judge
datetime与logging模块
Realize an air conditioner with compose to bring you cool in summer
Bytecode proof in appliedzkp zkevm (9)
错过金三银四,找工作4个月,面试15家,终于拿到3个offer,定级P7+
MySQL(一)
Pop up and push in sequence of stack < difficulty coefficient >
Please consult me. I run the MYSQL to MySQL full synchronization of flykcdc in my local ide. This is in my local ide
Cisco * VRF (virtual route forwarding table)
sentinel