Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 如何在所有浏览器(例如,Chrome和Firefox)中获得相同的innertext ptoperty值_Google Chrome_Internet Explorer_Selenium_Coded Ui Tests - Fatal编程技术网

Google chrome 如何在所有浏览器(例如,Chrome和Firefox)中获得相同的innertext ptoperty值

Google chrome 如何在所有浏览器(例如,Chrome和Firefox)中获得相同的innertext ptoperty值,google-chrome,internet-explorer,selenium,coded-ui-tests,Google Chrome,Internet Explorer,Selenium,Coded Ui Tests,我是硒的新手。我正在使用CUIT进行跨浏览器测试。每当我在IE中录制动作并在chrome中播放时,我的测试都会失败,因为IE和chrome中的innertext属性值不同 我的大多数测试脚本都依赖于innertext属性 在所有浏览器中,是否有任何方法可以让通用转换器获得相同的innertext属性值 如果我使用Selenium在所有浏览器中测试我的应用程序。selenium是否在所有浏览器中返回相同的innertext值 CUIT论坛查询链接innerText是Internet Explore

我是硒的新手。我正在使用CUIT进行跨浏览器测试。每当我在IE中录制动作并在chrome中播放时,我的测试都会失败,因为IE和chrome中的innertext属性值不同

我的大多数测试脚本都依赖于innertext属性

在所有浏览器中,是否有任何方法可以让通用转换器获得相同的innertext属性值

如果我使用Selenium在所有浏览器中测试我的应用程序。selenium是否在所有浏览器中返回相同的innertext值

CUIT论坛查询链接

innerText是Internet Explorer使用的旧方法。相反,你可以使用文本内容

以下是代码:

  var domElement = document.getElementById("txtUserName");      
  var output = domElement.textContent || domElement.innerText;

如果您在项目中使用jQuery,则可以使用.text,因为它旨在支持跨浏览器

Hi Rahul,感谢您的快速回复。你能分享更多关于DomeElement的信息吗。我只知道CUIT,即UITestControl。但是UITestControl上没有textContent属性。DomeElement是网页/文档中存在的元素,我们可以通过Document.getElementbyId获取该元素。请检查我是否编辑了我的答案。嗨,Rahul,我已经开发了一些使用innerText属性的测试。innerText和TextContent属性之间的确切区别是什么。有没有办法从innerText属性值或viceversa@RajDiscussionInternet explorer使用innerText属性,Firefox使用textContent属性。因此,修改代码,比如var output=domElement.textContent | | domElement.innerText;。因此,它可以在跨浏览器上工作。当然,这与Selenium或CodedUI无关,但取决于浏览器如何返回innerText?!