Get Value/Text of Order-Quantity

Hi! I struggle with the following Problem in Web Testing: I want to get the value of the quantity of a product.
In more detail: Besides of a product I have a field with the two buttons - (remove one piece) and + (add one piece) with the quantity in the middle. Looks like the following: [-] n [+]
I guess you know what I mean.
Now I want to get the value of n. I tried different xPath’s with getAttribute and getText, but it really does not work. Do you have an Idea how I can get the value? Is the problem the xpath?

Mabe the source code of the webpage help?
The value is the 47 (i.e., at this moment, 47 pieces are in the shopping cart).

        <input type="hidden" name="entryNumber" value="4"/>
        <input type="hidden" name="productCode" value="Z699960"/>
        <input class="steelqm" type="hidden" name="initialQuantity" value="**47**"/>
        <label for="quantity4" class="visible-xs visible-sm"></label><button type="button" class="btn btn-default button-quantity button-quantity-remove">-</button>
            <input id="quantity_4" name="quantity" class="form-control js-update-entry-quantity-input input-quantity" type="text" value="**47**" size="1"/><button type="button" class="btn btn-default button-quantity button-quantity-add">+</button>

Hope you can help me out with nice ideas!


This element is both visible and has an ID attribute… this is the element you want to target:

You can use CSS or XPATH, either will work, just make sure you’re targeting that ID (you can uncheck everything else).

Here’s the css:


Nice it works now! However, it does work with Attributes. XPath did not work for some reason. I don’t care, im happy :smiley: Thanks!