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"

 Enter image details here

  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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -