简体   繁体   English

如何使用 Karate UI Automation 在基于 yaml 的 UI 上输入值

[英]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')
  • script(element, "_.innerHTML='100'") - worked, but the value '100' however was not persisted till saving it. script(element, "_.innerHTML='100'") - 有效,但值 '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.

相关问题 Kendo UI Grid:如何根据位值更改单元格文本 - Kendo UI Grid: How to change cell text based on a bit value 如何根据JQuery UI范围幻灯片值缩放图像? - How to zoom image based off JQuery UI range slide value? 更新“值”=属性<input>在更改 UI 中的值时或在按下输入时 - Update "value"= attribute of <input> on changing the value in UI or When enter Pressed 空手道 UI 中的 ShadowRoot dom 元素访问问题 - ShadowRoot dom elements access issue in Karate UI 用于构建自动化的Web UI管道 - Web UI Pipeline for build automation 如何在按下 Enter 键时专注于 Material UI 按钮 - How to focus on a Material UI Button while Enter key pressing 如何使用带有 ENTER 键的 JQuery UI 菜单? - How do you use JQuery UI menu with ENTER key? 如何根据 ui 中选择的输入值在服务器中获取 output 值? - How do I get output value in server based on selected input value in ui? 如何使用自定义逻辑使用“ENTER”键打开 jQuery-UI-Selectmenu 下拉菜单? 文档只允许打开“SPACE”键,但不允许打开“Enter”键 - How to open jQuery-UI-Selectmenu dropdown using 'ENTER' key using custom logic? Documentation only allows 'SPACE' key to open but not 'Enter' key 网页上的Windows UI自动化 - Windows UI Automation from a Web Page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM