cancel
Showing results for 
Search instead for 
Did you mean: 

how to read dynamic attribute value

mark_fryu
Participant
View Entire Topic
Dennis_Suck85
Participant
0 Kudos

Dear Mark_Fryu,

To read the value of an attribute from an XML file, you can use an XPath query. Since the attribute doesn't have a fixed value, you'll use a general query
to extract the attribute instead of a specific value.
Let's assume you've created a WebDriver object and are on the page containing the XML document, or have already loaded it.
Reading the attribute might then look like this in Java code (Java is used as an example here, and depending on your preferred language, you can of
course use a different language)



// Create the object
WebDriver myDriver = new ChromeDriver();
// Load the XML-File
myDriver.get("Filepath");
// Read the attribute
String attributeVal = myDriver.findElement(By.xpath("//tes2")).getAttribute("ns1:testattribute");

...

Best regards

Dennis