Jump to content

How to define Webdriver $sSelector or $_WD_LOCATOR in element <a class="btn btn-grad-orange" href="/wallet/login.asp">Login</a>


Go to solution Solved by SOLVE-SMART,

Recommended Posts

Posted

How to define Webdriver $sSelector or $_WD_LOCATOR in this element below:

<a class="btn btn-grad-orange" href="/wallet/login.asp">Login</a>

Can i use $_WD_LOCATOR_ByXPath for this?

Thank You

Posted (edited)
5 hours ago, Danp2 said:

Yes, you can use any type of selector you would like to use. Have you tried using _WD_LinkClickByText?

No, I haven't tried _WD_LinkClickByText

 

but

How to use $_WD_LOCATOR_ByXPath in my case?

Edited by HezzelQuartz
  • Solution
Posted (edited)

Hi @HezzelQuartz 👋 ,

my assumption is something like this:

<body>
    <div>
        <form>
            <a class="btn btn-grad-orange" href="/wallet/login.asp">Login</a>
        </form>
    </div>
</body>

Now only some of the locator strategy options:

; XPath selector
//a[@href='/wallet/login.asp']

//a[contains(@href, 'login.asp') and text()='Login']


; CSS selector
a[href='/wallet/login.asp']


; or by link text
; or by class name
; or by tag name

In AutoIt (au3WebDriver), I personally use XPath as default locator strategy. In other frameworks like WebdriverIO, (Selenium) or Playwright, I often use CSS selectors. You can generate several of them directly in Chrome (for example). See the following screenshot:

chrome-xpath-generation.png

  • Open the Browser DevTools with F12.
  • (1) right click on your target element
  • (2) copy > (3) choose your locator strategy
  • now use it in AutoIt 😀

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Posted
2 hours ago, SOLVE-SMART said:

Hi @HezzelQuartz 👋 ,

my assumption is something like this:

<body>
    <div>
        <form>
            <a class="btn btn-grad-orange" href="/wallet/login.asp">Login</a>
        </form>
    </div>
</body>

Now only some of the locator strategy options:

; XPath selector
//a[@href='/wallet/login.asp']

//a[contains(@href, 'login.asp') and text()='Login']


; CSS selector
a[href='/wallet/login.asp']


; or by link text
; or by class name
; or by tag name

In AutoIt (au3WebDriver), I personally use XPath as default locator strategy. In other frameworks like WebdriverIO, (Selenium) or Playwright, I often use CSS selectors. You can generate several of them directly in Chrome (for example). See the following screenshot:

chrome-xpath-generation.png

  • Open the Browser DevTools with F12.
  • (1) right click on your target element
  • (2) copy > (3) choose your locator strategy
  • now use it in AutoIt 😀

Best regards
Sven

Thank You

Really Helpful for me

Posted (edited)

@SOLVE-SMART
 

<body id="body-overlay">
    <div class="xyz-content">
        <div class="container">
            <div class="xyz-wrapcontent">
                <div id="history" class="xyz-history-container">
                    <div class="xyz-history-content">
                        <div id="tbl" class="xyz-history-table-content">
                            <table class="table table-hover table-sm table-striped" style="width:100%">
                                <tbody>
                                    <tr>
                                        <td>
                                            <ul>
                                                <li>
                                                    ::marker
                                                    <strong>Transaction ID:</strong>
                                                    4537988
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <ul>
                                                <li>
                                                    ::marker
                                                    <strong>Transaction ID:</strong>
                                                    4537107
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <ul>
                                                <li>
                                                    ::marker
                                                    <strong>Transaction ID:</strong>
                                                    4537092
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                </tbody>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>


how about my example above?
How to use Webdriver to get first, second, and third Transaction ID? 
I Want to get the text

Or Maybe I Think I should create new thread

Edited by HezzelQuartz
Posted (edited)

Hi @HezzelQuartz ,

new threads are often the better way, yes. So my answer (possible solution) can be found in through 🔗 this post.

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...