简体   繁体   中英

Selenium on getting span innerhtml

<div id="ctl00_cphRoblox_rbxGroupFundsPane_GroupFunds" class="StandardBox" style="padding-right:0">
<b>Funds:</b> 
<span class="robux" style="margin-left:5px">128</span>
</div>

Ok so I want to get the 128 but sometimes it gives me "18" and I have no idea

I tried:

dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.ClassName("robux")).GetAttribute("innerHTML"));

and

dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.ClassName("robux")).GetAttribute("textContent"));

要获取文本128 ,可以使用以下代码行:

dcWeb.SendMessage(s + " = Pending and Robux: " + driver.FindElement(By.XPath("//div[@class='StandardBox' and contains(@id,'_cphRoblox_rbxGroupFundsPane_GroupFunds')]//span[@class='robux']")).GetAttribute("innerHTML"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM