querySelectAll -with webdriver script does not work
search cancel

querySelectAll -with webdriver script does not work

book

Article ID: 199204

calendar_today

Updated On:

Products

CA App Synthetic 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”')

Environment

Release : SAAS

Component : CA APP SYNTHETIC MONITOR (WATCHMOUSE)

Cause

script error

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.