ROBIN NINAN
ROBIN NINAN

Reputation: 13

How can i detect a button in taiko js

I'm trying to detect a button on my simple angular page. On checking that the button exists, it always returns false whilst the text search always return true.

console.log(await button('New Page').exists()); - false
console.log(await button(below('title')).exists()); - true
console.log(await text('New Page').exists()); - true

the html component looks a bit like this.

<button class="new-page-button" routerlink="/next" tabindex="0">
<span class="mat-button-wrapper"> New Page </span>
<div class="mat-button-ripple mat-ripple" matripple=""></div>
<div class="mat-button-focus-overlay"></div>
</button>

I would expect that the button function in taiko would be able to detect the button with text "New Page".

There isn't much help around this topic. Any help would be much appreciated.

Upvotes: 1

Views: 1651

Answers (2)

Kavitha Sivalingam
Kavitha Sivalingam

Reputation: 1

As of today, 14-Jan-2020, I am using Gauge # 1.0.6 and able to locate the button with child tag as mentioned in the query, so I hope it is updated with the new request. This is how my HTML code looks like: <button _ngcontent-lyu-c3="" class="full-width loginButton mat-raised- button mat-primary ng-star-inserted" color="primary" mat-raised-button="" mattooltip="Login with Okta" aria-describedby="cdk-describedby-message-35" cdk-describedby-host="" style="touch-action: none; user-select: none; - webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"> <span class="mat-button-wrapper"> Login with Organization </span><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat- button-focus-overlay"></div></button>

This is my step: * Login page should have "Login with Organization" button

And I can able to identify in my step implementation like this:step("Login page should have <arg0> button", async function(arg0) { await button(arg0).exists(); });

Upvotes: 0

bugdiver
bugdiver

Reputation: 26

Currently, taiko does not search for buttons which has child elements with matching text. There is an open issue for the same. Please follow https://github.com/getgauge/taiko/pull/833 to get updates on the issue.

Upvotes: 0

Related Questions