javascript - How to find an element by searching with InnerHTML using C# and Selenium -
I have to get a special element ID by searching for the milling interiors HTML string. For example, I want to find element ID in which the internal HTML is the "beginning of the car"
select public static bundle some (IWebDriver driver, string search name) {var js = driver IJavaScriptExecutor; If incorrect (js ==) wrong return; Var element = (string) js.ExecuteScript ("... to get script to get ID ..."); Var x = Driver. Fund Element (By ID); X.Click (); Back true; } I know that it is possible through loops and they all get them using Javascript, but once you find the internal matching with the 'SearchName' string Get HR, How do I return the ID?
Using jQuery is simple, just use: in -
var found = $ ("TD: happens ('start of car')"). Ether ('id'); This allows you to return the ID of the element in question.
Alternatively here's just one way to do this with JavaScript -
function text id (node, text) {if (node.nodeValue == text) {return node.parentNode; } For (var i = 0; i & lt; node.childNodes.length; i ++) {var return value = textID (node. Childnodes [i], text); If (return value = null) {return return value; }} Return tap; }
Comments
Post a Comment