0

In our app that we are using, there are widgets on the page, lots and lots of widgets. There is a HTML tag called widgetkey in it, with an 'id' value associated with it.

Here is the exact HTML:

<div class="widget-wrapper form-group " widgetkey="xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">

I am hoping that I don't have to get all the elements by that tag name, and then loop through each widget element. The key value is the only thing that makes these widgets unique.

Also steering clear of Xpath, because some of these widgets can not be displayed, causing the widget I am looking for to move location and causing the Xpath to break. The only answer I saw used Xpath. I would rather loop in that case.

2

Using xPath should not be a problem. If you know widgetkey then you just use //div[@widgetkey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx']

So even if your widget is moved your xPath would not be broken.

  • ahhh!!!!! Got it. I see that. Now I know how to find lots of things I have written differently before! Wonderful..I used it mostly to get the embedded value, within an embedded row in a table, in a grid, inside a panel, etc etc....this..this is wonderful! Never thought of it like this. I appreciate that education...and a trophy for you for the quick quick response. – Greg P Jan 28 at 15:14
  • I am definitely going to mark this as answered, when I get it working. But this is what the html looks like....the widgetkey is the id name...but still not working...here is the exact html. <div class="widget-wrapper form-group " widgetkey="xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">. would that change the xpath? – Greg P Jan 28 at 15:48
  • @GregP see my update – Alexey R. Jan 28 at 15:53
  • 1
    Thank you, sorry for not initially putting in the html. I am going ot put it on the initial question so all the information is there. – Greg P Jan 28 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.