Karate Software - how to press button where header has specific value (not in direct path)

不羁的心 提交于 2021-01-28 23:32:52

问题


I have task when I want to press button with "Delete" caption according to string (picture attached). There are many these sections in application and I want to press the Delete button according to specific H6 string.

I need to write click action to find the code with H6 value (this time "app111") and click on the button Delete.

I have tried something like this "rightOf('app111').find('button').click() or below('app111').find('button').click()" in many variations but I was not successful.

In some cases (when the tags are in straight path works for me: click('{//*[normalize-space(text()) = \'' + appName + '\']/../../div/table/tbody/tr/td[2]/a[2]}'), but this time H6 and DIV are on the same level. Now the structure is (more on picture attached):

H6
DIV
  A
  DIV
    DIV
    A
    DIV
    A
    BUTTON
       SPAN

How to write button click according to H6 value (click on next "Delete" button after H6 with specific string)

Thank you for some help!


回答1:


Can you try near(): https://github.com/intuit/karate/tree/master/karate-core#near

Else I think you should write a little JS to get hold of the element. For some ideas, see this: https://stackoverflow.com/a/60800181/143475 and https://stackoverflow.com/a/60618233/143475

For example, I think once you select app111 which should be easy, you can get the div after it by getting element.nextSibling

Then you run querySelector('.btn-link') or something similar, and it should work.

Since you have pasted a screen-shot I can't help more, but if you can follow this process - I can take a look: https://github.com/intuit/karate/tree/develop/examples/ui-test



来源:https://stackoverflow.com/questions/61100923/karate-software-how-to-press-button-where-header-has-specific-value-not-in-di

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!