3

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.

4
  • I have would have done in JAVA like this... WebElement we = driver.findElement(By.className("star-rating")); String rating = we.getAttribute("data-rating"); Commented Feb 1, 2018 at 13:45
  • I don't know anything about the VBA syntax but I would expect that it exists. If it doesn't you can always use JS to get what you want assuming that VBA has the equivalent of JavascriptExecutor. Commented Feb 1, 2018 at 13:59
  • 1
    The correct syntax to get the rating is driver.FindElementByCss("[data-rating]").Attribute("data-rating"). Commented Feb 1, 2018 at 16:55
  • Thank you very much @Florent B. I will use the syntax you provided +1. Commented Feb 1, 2018 at 21:41

1 Answer 1

2

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"

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your solution. Unfortunately I got an error. Run-time error 438: Object doesn't support this property or method
Updated my answer. Let me know the status.
Same error again. I tried with absolute path as well:
Thank you very much for the information @DebanjanB. I think I will use css finder instead to solve the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.