C# Selenium QA - how to extract the value of custo

2020-08-01 08:03发布

I have complex DOM structure with dynamically changing values of the HTML id attributes. Selenium is returning "null" when I attempt to extract the values of the "custom" attributes.

I need to extract the value of parentId (namely I need the "qqq-bbb", which is different on every reload)

//Selenium(C#): 
// evaluates to "null"
string someStringName = someIWebElement.GetAttribute("parentId");
   

//HTML tag (example): 
// in Chrome the parentId is visible and unique
<g id="333-aaa" parentId="qqq-bbb"> 

   

1条回答
forever°为你锁心
2楼-- · 2020-08-01 08:47

Solution: (based on recommendation in comment#2). Issuing the following command returns as string the contents of the tag AND by applying the right parse you get the attribute value you need

string outerHTML = foundIWebElement.GetAttribute("outerHTML");

查看更多
登录 后发表回答