Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting attribute text from HTML using VBA selenium

Tags:

vba

selenium

I need to get the value "8.37" from the "data-rating" attribute.

<div class="ch-rating"> "VERYGOOD 8.37"
    <div class="star-rating star-rating--alt star-rating--ch" data-rating="8.37" style="">
            <span style="width: 83.7%;"></span>
    </div>
</div>

In java there is .getAttribute() but I can't find the syntax in VBA.

I guess its something like this:

bot.FindElementByXPath("//div[@data-rating]"). followed by some syntax.

like image 957
Sputnik Avatar asked Dec 06 '25 16:12

Sputnik


1 Answers

To get the value "8.37" from the "data-rating" attribute you can use the following line of code :

bot.FindElementByXPath("//div[@class='ch-rating']/div[@class='star-rating star-rating--alt star-rating--ch']").getAttribute("data-rating")

Update 1

HtmlElement.GetAttribute Method (String)

Syntax :

var attribute = element.getAttribute(attributeName);

where

  • attribute is a string containing the value of attributeName.
  • attributeName is the name of the attribute whose value you want to get.

Update 2 :

As you are seeing Run-time error 438: Object doesn't support this property or method for HtmlElement.GetAttribute Method (String) here are some details :

Error 438 occurs when running a program in which a form is assigned to a variable and that variable is used to access a control on the form if the program is on a system running Windows 95 with Regional Settings set to a setting other than English (United States). The error text is:

Run-Time Error #438:
Object doesn't support this property or method

Resolution

There are two possible workarounds for this problem.

  • Access the form directly rather than by a variable containing the form.
  • Create property procedures in the form's code to provide access to the properties of the controls on the form.

Status

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been fixed in Windows 98.

Trivia

To reproduce this bug consistently, you will need HeapWalker, a utility that ships with the Windows 16-bit Software Development Kit and the 16-bit version of Visual C++.

Steps to Reproduce :

  • From Control Panel, click Regional Settings to open the Regional Settings dialog box. Set the Regional Settings to English (Australian).
  • Start the 16-bit edition of Visual Basic 4.0. If it is already running, select New Project from the File menu.

Source : FIX: Error 438"Object Doesn't Support This Property or Method"

like image 109
undetected Selenium Avatar answered Dec 08 '25 10:12

undetected Selenium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!