# 5.13. Pass params though XPath string

Trong thực tế làm việc với Selenium, bạn sẽ thấy rất nhiều đối tượng chỉ khác nhau 1 giá trị trong xpath locator.

#### Dưới đây là một số ví dụ:

```
".//*[@id='bankList']/p[.='ANZ']"
".//*[@id='bankList']/p[.='HSBC']"
".//*[@id='bankList']/p[.='Barclays']"
```

Trong các ngôn ngữ lập trình đều hỗ trợ `String Format` để mình có thể ghép các chuối lại với nhau.

Java cũng có `String.format()` để giúp chúng ta tạo ra một `pattern` chung cho các locator có dạng như ví dụ ở trên.

#### Đầu tiên là định nghĩa locator string:

```
String bank = ".//*[@id='bankList']/p[.='%s']";
```

#### Sử dụng để tạo ra các locator cụ thể

```
String.format(bank, "ANZ"); //--> output :  ".//*[@id='bankList']/p[.='ANZ']"
String.format(bank, "HSBC"); //--> output :   ".//*[@id='bankList']/p[.='HSBC']"
String.format(bank, "Barclays"); //--> output :   ".//*[@id='bankList']/p[.='Barclays']"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tvn.gitbook.io/selenium-java/examples/pass-params-though-xpath-string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
