问题
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