你如何存储在一个javascript变量,硒元素的文字? [英] How do you store an elements text with selenium in a javascript variable?

查看:206
本文介绍了你如何存储在一个javascript变量,硒元素的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个网站:

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

我希望能够使用硒和JavaScript来存储在&LT的文本; H3&gt;在变量 (你好)titleText

I want to be able to use selenium and javascript to store the text in the <h3> (Hello) in the variable titleText .

我将使用该code在browsermob监控测试。

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

推荐答案

在BrowserMob你可以做

In BrowserMob you can do

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

,然后使用titleText就像您的任何变量。

and then use titleText like you would any variable.

这篇关于你如何存储在一个javascript变量,硒元素的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆