> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://uilicious.crisp.help/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Targeting Elements

1 - **Matching by text**
This matches by using either the text on screen, or aria labels. For example `I.click("login")`  or `I.fill("First Name","John")`
One thing useful is that when there are multiple text of the same text, it is sometimes useful to do an I.see("Unique text")  near the target text to interact with, think of it as instructing a user over the phone 😉

2 - **Matching by HTML/CSS class name**
Elements can be selected using HTML/CSS class name, with a dot prefix. For example `I.click(".login-button")`

3 - **Matching by HTML/CSS ID**
Elements can be selected using HTML/CSS ID, with a hash prefix. For example `I.click("#close")`

4 - **Matching by XPath**
Elements can be selected using XPath. For example `I.click('//*[@id="tsf"]/div[2]/div[3]/center/input[1]')`  

**Additional Note - Running actions inside an iframe**
Finally when interacting with elements inside an iFrame, especially with salesforce, SAP, Shopify. You can improve the accuracy by running actions within a selected iframe context. For example: 

```javascript
UI.context("#unique-iframe-id", function() {
   I.click("Button inside iframe")
   //... other actions
})
```