i have html class
<a class="mobile-nav-btn" href="/news-mobile"><img src="img/news.svg" role="presentation"><span>resources</span></a>
i trying click, assert or verify above present .
.click('a[class="mobile-nav-btn"][href="/news-mobile"]') .waitforelementvisible('body', 3000) .url(function(response){ console.log('the url is', response.value); this.assert.urlcontains(response.value, 'news-mobile') })
the above click failed because url not change. can see console. , after successful click. class turn mobile-nav-btn active
. below how attempt verify that. failed
.verify.elementpresent('a[class="mobile-nav-btn active"][href="news-mobile"]')
how achieved those? appreciated.
what should work you
change
.click('a[class="mobile-nav-btn"][href="/news-mobile"]') .waitforelementvisible('body', 3000) .url(function(response){ console.log('the url is', response.value); this.assert.urlcontains(response.value, 'news-mobile') })
to
.click('a.mobile-nav-btn[href="/news-mobile"]') .waitforelementvisible('body', 3000) .url(function(response){ this.assert.urlcontains(response.value, 'news-mobile') })
and
.verify.elementpresent('a[class="mobile-nav-btn active"][href="news-mobile"]')
to
.assert.cssclasspresent('a.mobile-nav-btn[href="/news-mobile"]','active')
your test failed because using selectors wrong.