• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Selenium Vba: Click button on web page |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Selenium Vba: Click button on web page |VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosSelenium Vba: Click button on web p…
sp_PrintTopic sp_TopicIcon
Selenium Vba: Click button on web page
Avatar
Rajsha B
India
Member
Members
Level 0
Forum Posts: 22
Member Since:
April 7, 2020
sp_UserOfflineSmall Offline
1
July 27, 2020 - 9:29 pm
sp_Permalink sp_Print

Hi Team, Im trying to click on the below button but i couldn't, below is the html code i have.

I tried with xpath like

  driver.FindElementByXPath("//a[contains(text(),'https']").Click

  driver.FindElementByXPath("//a[@href,'#']").Click   ' this work, but this clicks on sign out drop down button

  driver.FindElementByXPath("//a[@class,'btn btn-default']").Click

Could some one help me in this. Thanks

<a href="#" class="btn btn-default" data-bind="click : downloadFiles, visible: $root.attachmentsViewModel.files().length > 0">
<i class="fa fa-download js-app-action-el" aria-hidden="true"></i>
Download <strong data-bind="text:$root.attachmentsViewModel.files().length">5</strong> Files
</a>

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
July 27, 2020 - 10:50 pm
sp_Permalink sp_Print

Hi,

It'll be easier to do if you can supply the url of the page rather than just having a fragment of the age to work with.

regards

Phil

Avatar
Rajsha B
India
Member
Members
Level 0
Forum Posts: 22
Member Since:
April 7, 2020
sp_UserOfflineSmall Offline
3
July 28, 2020 - 12:32 pm
sp_Permalink sp_Print

Hi Philip, thanks for the immediate reply.. I don't have rights to send the URL details.. that is the reason I have not included URL in the post. When I checked, I for the above html code for that particular button... Is it possible to guide with that code .. Thanks

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
July 28, 2020 - 12:48 pm
sp_Permalink sp_Print

Hi Rajsha,

If it's not publicly accessible or requires a login, can you at least view the page source code and copy/paste that into a text file.

There are some techniques of locating elements that require the entire page to be known, for example, locating the nth <a> tag.  Without knowing how many <a> tags, or buttons, are on the page, I can't properly use that approach.

Phil

Avatar
Rajsha B
India
Member
Members
Level 0
Forum Posts: 22
Member Since:
April 7, 2020
sp_UserOfflineSmall Offline
5
July 28, 2020 - 10:48 pm
sp_Permalink sp_Print sp_EditHistory

Hi Philip,

I found the solution for the button, below is the code that i have found to click on the button.

.FindElementByXPath("//a[@class='btn btn-default'][1]").Click

Since in the 4th post you stated (locating the nth <a> tag.) this gave me the clue to find the above code. There are 5 buttons total i the web page and the button i need is located the 2nd place of a> tag.

Thank you Philip for the idea.

Thanks

Rajsha

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
July 28, 2020 - 10:55 pm
sp_Permalink sp_Print

No worries.  That's why I needed the whole page so I could count things like that 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Riny van Eekelen, michael serna
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6214
Posts: 27246

 

Member Stats:
Guest Posters: 49
Members: 31897
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.