-1

I wanted to read the text of "TestData.txt" from the below HTML Code. There is huge html code in the original page. Sharing the below content for reference. There are few more input tags on the top to the below mentioned HTML code.

Can you please correct the below step definition code ?

Step Definition

TestObject testObj5 = new TestObject().addProperty("xpath", ConditionType.EQUALS, "//input[@value='TestData.txt']??")
inq = WebUI.getText(testObj5)

HTML Code

<input type="file" name="file_attach_text" accept="text/html" value="TestData.txt" onkeypress="if(chkKey(event)){return false;}" id="attach_text" class="button" title="Opens a dialog box to select files">
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Venkat D
  • 41
  • 6

1 Answers1

0

You can select the element using the xpath with the name attribute and then get the value like this:

TestObject testObj5 = new TestObject().addProperty("xpath", ConditionType.EQUALS, "//input[@name='file_attach_text']")
inq = WebUI.getAttribute(testObj5, "value")
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77