[英]How to enter a value on yaml based UI using Karate UI Automation
Here is the ui app screenshot- its a yaml page这是 ui 应用程序屏幕截图 - 它是一个 yaml 页面
The UI is a code editor, used to enter or update yaml/json content. UI 是一个代码编辑器,用于输入或更新 yaml/json 内容。 I am trying to update 'value1' using the karate UI syntax's and it didnt seem to work, below are the trials
我正在尝试使用空手道 UI 语法更新“value1”,但它似乎没有用,以下是试验
* string element = "//span[text()='Parent']/following::span[text='Child1']/following::span[text='value1']
#Syntax Approaches: #语法方法:
* script(element, "_.innerHTML='100'")
* script(element, "_.innerHTML='value1'").input('100')
And waitFor(element).input('100')
* input(element, '100')
When value(element, '100')
* locate(element).input('100')
sample app - https://onlineyamltools.com/edit-yaml示例应用程序 - https://onlineyamltools.com/edit-yaml
sample yaml -样品 yaml -
** **
parent:
child:
key1: value1
key2: value2
child2:
key3: value3
key4: value4
** **
element locator: //span[text()='parent']/following::span[contains(text(),'child')]/following::span[contains(text(),'value1')]
元素定位器:
//span[text()='parent']/following::span[contains(text(),'child')]/following::span[contains(text(),'value1')]
All I need is to be able to update the 'value1' to '100' and save it.我所需要的只是能够将“value1”更新为“100”并保存它。 Thanks
谢谢
Use the script function to set the innerHTML property of the element to the new value:使用脚本 function 将元素的 innerHTML 属性设置为新值:
* script(element, "_.innerHTML='100'")
Use the input function to set the value of the element to the new value:使用输入 function 将元素的值设置为新值:
* input(element, '100')
Use the value function to set the value of the element to the new value:使用值 function 将元素的值设置为新值:
* value(element, '100')
It's not clear from your question whether the value of the element is being updated in the web page, or whether the changes are being lost when you save the page.从您的问题中不清楚元素的值是否正在 web 页面中更新,或者更改是否在您保存页面时丢失。
If the changes are being lost when you save the page, it's possible that there is some JavaScript code on the page that is resetting the value of the element when the page is saved.如果保存页面时更改丢失,则页面上可能有一些 JavaScript 代码在保存页面时重置元素的值。 In that case, you may need to use a different approach to update the value of the element.
在这种情况下,您可能需要使用不同的方法来更新元素的值。
The below karate code/syntax works for all the UI's having code editors as the one posted in the original question:以下空手道代码/语法适用于所有具有代码编辑器的用户界面,如原始问题中发布的那样:
* mouse(element).click()
* input(element, [Key.DELETE, Key.DELETE, Key.BACK_SPACE, Key.BACK_SPACE, '100'])
The Keyboard events can go in the array and may differ based on the scenario.数组中的键盘事件可以是 go,并且可能会因场景而异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.