How to update a value on website with changing ID or class - VBA selenium

Viewed 19

I'm trying to update the value 1.000000 with different number on private website. The problem is that I can not use FindElementByID keeps changing, as the number inside of ID keeps changing. Could anyone advise? I've tried to print the attribute but it didnt work. the element "1.000000" can not be found.

VBA code:

 Dim POamount As Selenium.WebElements
 Set POamount = CD.FindElementByLinkText("1.000000")
 Debug.Print POamount(1).Attribute("value")

HTML code:

<td align="center" nowrap="nowrap"><span id="order_header_change_order_line_change_attributes_6712074_price_field">
<input size="12" title="Price" aria-disabled="false" value="1.000000" type="text" name="order_header_change[order_line_change_attributes][6712074][price]" id="order_header_change_order_line_change_attributes_6712074_price">
<input type="hidden" value="46" name="order_header_change[order_line_change_attributes][6712074][currency_id]" id="order_header_change_order_line_change_attributes_6712074_currency_id">
</span>
</td>

1 Answers

I have found a way. I've used FindElementByCss and I used just part of the ID, without the changing number.

VBA:

CD.FindElementByCss("*[id^='order_header_change_order_line_change_attributes'][id$='price']").Clear
CD.FindElementByCss("*[id^='order_header_change_order_line_change_attributes'][id$='price']").SendKeys [D2]
Related