Click on span element in Ariba Network Buyer

mirelmo67

New Member
Joined
Feb 14, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello everybody.
I need to automate the logon into Ariba Network Buyer and, for that, I need to click on the "Next" button in the first screen (after introducing the user name).
But that button is a span element and all my efforts till now were useless - no success with "click" method neither with "onmousedown". Below is my code:

Sub automateAriba()

Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLSpans As MSHTML.IHTMLElementCollection
Dim HTMLSpan As MSHTML.IHTMLElement

IE.Visible = True
IE.Navigate "Ariba Network Buyer"

Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop

Set HTMLDoc = IE.Document
Set HTMLInput = HTMLDoc.getElementById("userid")
HTMLInput.Value = "mirelmo"


Set HTMLSpans = HTMLDoc.getElementsByTagName("span")

For Each HTMLSpan In HTMLSpans
' Debug.Print HTMLSpan.className, HTMLSpan.tagName, HTMLSpan.ID, HTMLSpan.innerText
' Debug.Print HTMLSpan.getAttribute("classname")
If HTMLSpan.className = "next-button-text" Then
HTMLSpan.Click
Exit For
End If

Next HTMLSpan

End Sub

Here is a capture from HTML code for that element:
1644858284692.png


Thank you.
Mirel
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hello,​
try with its parent "<a" ID 'cause the span element is obviously not the button …​
 
Upvote 0
Hello Marc.

Thank you for the idea but, unfortunately it doesn't work even if have taken into account the parent "<a" - see below code changed in "For" loop:

Sub automateAriba2()

Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLAs As MSHTML.IHTMLElementCollection
Dim HTMLA As MSHTML.IHTMLElement

IE.Visible = True
IE.Navigate "Ariba Network Buyer"

Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop

Set HTMLDoc = IE.Document
Set HTMLInput = HTMLDoc.getElementById("userid")
HTMLInput.Value = "mirelmo"


Set HTMLAs = HTMLDoc.getElementsByTagName("a")

For Each HTMLA In HTMLAs
' Debug.Print HTMLA.className, HTMLA.tagName, HTMLA.ID, HTMLA.innerText
If HTMLA.ID = "_nizztc" Then
HTMLA.Click
Exit For
End If

Next HTMLA

End Sub

I ran step by step, the "if" condition has been met (the ID "_nizztc" is recognized) but "HTMLA.Click" didn't work.

You can try on your computer to verify the new code.

Please, do you have any other idea on how to pass this step?

The result of clicking the "Next" button is opening the next screen for logging into Ariba, where the password should be filled.

Many thanks!
 
Upvote 0

Maybe the 'button' needs first to have the focus before to be clickable …​
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top