ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

querySelectAll -with webdriver script does not work

book

Article ID: 199204

calendar_today

Updated On:

Products

CA App Synthetic Monitor NIMSOFT CLOUD USER EXPERIENCE MONITOR DX Application Performance Management

Issue/Introduction

Trying to do a querySelectAll to get this link <a href="#" class="logout">Logout</a>.  But the code is not having any luck in getting it.

 

So the javascript code I am trying to use is:

document.querySelectorAll('[class="logout"]')

 

But that doesn’t seem to return anything, so I also tried:

document.querySelectorAll('[href=”#” class=”logout”')

Cause

script error

Environment

Release : SAAS

Component : CA APP SYNTHETIC MONITOR (WATCHMOUSE)

Resolution



document.querySelectorAll('a.logout') is the correct syntax to select the link.

Running this command on the page produces a NodeList object containing two items. Calling document.querySelectorAll('a.logout')[0].click(); logs out the user.