Using C # WATIN, how do I get the value of the html element of an INPUT tag?

Using C # WATIN, how do I get the value of the second occurrence of the html element of the INPUT tag on the page?

I tried a bunch of things and did not succeed. The debugger does not give me an obvious way to get the item [1] among the returned 4.

Console.WriteLine(ie.Element(Find.ByClass("myclass")).GetAttributeValue("value")  ) ;  
// works but prints the value of the 1st of 4 input elements on the page

Console.WriteLine(ie.ElementsWithTag("input", "text").Length.ToString()  ); 
// returns the number 4

Console.WriteLine( ie.Element(Find.ByName("login")).GetAttributeValue("value")  );
// works but its not safe since its possible there might be two elements with the name login

Basically, I want to be able to select an input element by array index .

+3
source share
4 answers

This can help:

        ElementCollection elementCol = ie.Elements;
        elementCol = elementCol.Filter(Find.ByClass("myclass"));
        string value = elemntCol[1].GetAttributeValue("value");
+3
source

Try

ie.Element(Find.ByIndex(1))
0
source

? , ( , / ;-):

TextFieldCollection textFields = browser.TextFields;  
foreach (var field in textFields)  
{  
    if (field.Id == "humbuggery")...  
} 
0

, , , , :

ie.Link(new IndexConstraint(1) && Find.ByName("linkname"))

. .

0
source

Source: https://habr.com/ru/post/1748613/


All Articles