The Agile Way

The Agile Way

Selenium Training Workbook

13 Sony Playstation Login Test

Using text() in Xpath expression

Zhimin Zhan's avatar
Zhimin Zhan
Dec 02, 2022
∙ Paid

Learning Objectives

  • Review

    • New Test Project

    • AJAX testing

  • Using `text()` in XPath

  • Using the parent node in Xpath to be more specific

Test Case 13

Please note this is a public site (which I don’t have control of, different from Agile Travel), so the site may change.

Tasks

Task 1. Click the “Sign In”

Right-click the “Sign In” and inspect.

This is not a hyperlink (`<a href`), we cannot use the LINK_TEXT locator. Within the identified `SPAN` tag, there are no easy identifiers such as ID, NAME, or even a good attribute for identification.

<button data-qa="web-toolbar#signin-button"> 
  <span class="psw-fill-x psw-t-truncate-1 psw-l-space-x-2 ">Sign In</span>
</button>

The element’s classes `psw-fill-x` are all quite generic, i.e., which are used by many other elements, so we can’t use them.

Therefore, this leads to the natural thought to use the text `Sign In`. We can use it in XPath as below.

Keep reading with a 7-day free trial

Subscribe to The Agile Way to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zhimin Zhan
Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture