Script not working

Hi Respected Members,

Apologies if it is not the right board to post this query
also if this question is already asked [unfortunately I couldn’t find it…plz refer me ]

I am working on react application…using a private instance of WPT.

This is my targetted script flow.
page -1
launch app : navigate
click on the login button : execAndWait document.querySelector(‘.wds-c-navbar a[href=“#/login”] .wds-c-button’).click()

page -2
enter credentials : exec document.querySelector(‘.wds-c-form-item input#username’).value=“username”
exec document.querySelector(‘.wds-c-form-item input#password’).value=“password”
click login : execAndWait document.querySelector(‘button.wds-c-button–success[type=“submit”]’).click()

page -3
click a button [on logged in dashboard] : execAndWait document.querySelector('.wds-c-button–primary’).click()

I am using javascript commands to achieve this.

The problems I m facing whenever I navigate to a new page I m unable to run actions.
i.e after clicking on the login button on page-1, it takes me to page-2 where I can enter credentials and click the login button. here I m not able to click on login button.

but when I navigate to page-2 directly using navigate, the same click on login button is working.

Any help would be highly appreciated. Please let me know what I m missing.