在Selenium WebDriver中区分b / w getText()和getAttribute()? [英] Difference b/w getText() and getAttribute() in Selenium WebDriver?

查看:125
本文介绍了在Selenium WebDriver中区分b / w getText()和getAttribute()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两者都用于获取标签之间的WebElement值?
请更新我的假设是否正确。如果错了请详细说明。

Both are used to get the WebElement value in between tags? Kindly update whether my assumption is right. If wrong please elaborate it.

推荐答案

  <input attr1='a' attr2='b' attr3='c'>foo</input>

getAttribute(attr1)你得到'a '

getAttribute(attr2)你得到'b'

getAttribute(attr3)你得到'c'

getText()没有参数你只能得到'foo'

getText() with no parameter you can only get 'foo'

这篇关于在Selenium WebDriver中区分b / w getText()和getAttribute()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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