xBamboochax xBamboochax - 1 year ago 75
jQuery Question

Find element by part of id-selenium web driver

Hi guys I have element which has these atr :

<input type="text" class="id-element clearable ui-input-text ui-body-a" data-mini="true" maxlength="50" id="bec563ae2-AccountUser_Name">

And I want it find by
, but the part of
is automatic generated for every single user.
Then using will don´t work:

IWebElement profilUser = driverGC.FindElement(By.Id("id"));

Yep there is still way to find it by
(but it doesn´t work correctly here) or by
, but if I try to find it by
, I will get into some part of this element, but I will not be able to work with it(filling name).

Ok I tried this one, but unsuccessfully :

IWebElement profilUserName = driverGC.FindElement(By.CssSelector(".ui-page-active .msls-dialog-inner-frame .msls-tab-content .msls-first-row .msls-presenter-content .div:nth-child(1)"));

Answer Source

Seems like you are looking for an element with an ID that ends with a specific string: Here is how to do it using css selector

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download