Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 views
in Technique[技术] by (71.8m points)

Karate UI: Locating text via CSS

I'm regularly hitting odd visible page text that karate cannot see, likely due to some funky JS magic that I don't fully understand.

Example image shows text on the page generated after clicking on a translate button: enter image description here I'm trying to assert that the translated text is present and correct on the page.

This is the selector: #results-panel > div > div > div.thread > div > div.activity.panel.panel-default > div.panel-content > div > div:nth-child(2) > div:nth-child(1) > div > div.analysedText-translation > div > span:nth-child(3)

Example snippet of the element: enter image description here

Using the wildcard {} or {^} doesn't work. eg waitFor('{^}A few random things about cats') returns a null

I played around with CSS selectors and am able to highlight the text using:

  • highlight('.analysedText-translation > div > span:nth-child(3)')[0]

I was thinking maybe using waitForText but not sure how to apply it. Any suggestions?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The reason the docs don't talk much about CSS selectors is that it is a standard. BTW this is open source, you are welcome to contribute pull-requests to improve the documentation.

UI automation is hard, I'm not going to claim that any framework makes it magically easier.

Suggestions:

If still stuck, follow this process so that we can fix anything in the framework if needed: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...