Reputation: 3736
I am a big fan of Karate and exploring Karate UI for the end to end testing but stuck on one simple thing which is finding element by attribute where element contains special charatcers like below
<input autocapitalize="none" autocomplete="on" autocorrect="off" name="session[username_or_email]" spellcheck="false" type="text" dir="auto" data-focusable="true" class="r-30o5oe r-1niwhzg r-17gur6a r-1yadl64 r-deolkf r-homxoj r-poiln3 r-7cikom r-1ny4l3l r-1inuy60 r-utggzx r-vmopo1 r-1w50u8q r-1lrr6ok r-1dz5y72 r-1ttztb7 r-13qz1uu" value="">
This is the html snippet taken from Twitter login page. To get this control I have tried various options from mentioned below but couldn't able to find the control
Option 1
Given driver 'https://twitter.com/login'
And input('#session[username_or_email]',['[email protected]',Key.ENTER], 100)
And input('#session[password]',['asasas', Key.ENTER], 100)
When submit().click("click('{span}Log in')")
#* def elements = locateAll('{div}Click Me')
Then locate('.css-901oao').exists
Option 2
Given driver 'https://twitter.com/login'
And input('input[name=session[username_or_email]]', '[email protected]')
When submit().click("click('{span}Log in')")
Then locate('.css-901oao').exists
I above tried options I couldn't able to find input and span button. Any help or pointer will be very helpful.
Upvotes: 1
Views: 2484
Reputation: 58088
Here you go, note how you can use double-quotes when needed. I'm also giving an alternate approach, input[type=text]
would have also worked:
* input("input[name='session[username_or_email]']", 'hello')
* input('input[type=password]', 'world')
* click('div[role=button]')
Upvotes: 1