开发者

How do you store an elements text with selenium in a javascript variable?

开发者 https://www.devze.com 2023-01-17 03:15 出处:网络
I have this html: <div class=\"title\"> <div class=\"subtitle\"> <div id=\"flhcd1> <h3>Hello</h3>

I have this html:

<div class="title">
<div class="subtitle">
<div id="flhcd1>
<h3>Hello</h3>
<span></span>
</div>
<div class="subtitle2">
</div>
</div>

I want to be able to use selenium and javascript to store the text in the <h3> (Hello) in the variabl开发者_如何转开发e titleText .

I will be using this code in browsermob for monitoring tests.


In BrowserMob you can do

var titleText = selenium.getText("//div[@id='flhcd']/h3");

and then use titleText like you would any variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消