简体   繁体   English

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

[英]How can I get same innertext ptoperty value in all browsers (IE, Chrome and Firefox)

I am new to selenium. 我是硒新手。 I am doing cross browser testing using CUIT. 我正在使用CUIT进行跨浏览器测试。 Whenever I record action in IE and playback in chrome my tests are failing because of innertext property value is different in IE and Chrome. 每当我在IE中记录操作并在chrome中播放时,由于IE和Chrome中的innertext属性值不同,测试都会失败。

Most of my test scripts are depending on innertext property. 我的大多数测试脚本都取决于innertext属性。

Is there any way (common converter) to get same innertext property value in all browsers? 有没有办法(通用转换器)在所有浏览器中获得相同的innertext属性值?

If I use Selenium to test my application in all browsers. 如果我使用Selenium在所有浏览器中测试我的应用程序。 Is selenium returns same innertext value in all browsers? 硒是否在所有浏览器中返回相同的内部文本值?

CUIT forum query link https://social.msdn.microsoft.com/Forums/vstudio/en-US/201b6822-5ea9-4a8f-983d-fcc5d3d12f0b/cross-browser-testing-in-coded-ui-problem-with-considering-spaces?forum=vstest#86a5bacb-fbc5-4224-983f-d43504c693b0 CUIT论坛查询链接https://social.msdn.microsoft.com/Forums/vstudio/en-US/201b6822-5ea9-4a8f-983d-fcc5d3d12f0b/cross-browser-testing-in-coded-ui-problem-with-考虑空间?forum = vstest#86a5bacb-fbc5-4224-983f-d43504c693b0

innerText is old way of using with Internet Explorer. innerText是与Internet Explorer结合使用的旧方法。 Instead you can use textContent . 相反,您可以使用textContent

Here's code: 这是代码:

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

If you are using jQuery in your project, you can use .text() since it is designed to support cross-browsers 如果您在项目中使用jQuery,则可以使用.text(),因为它旨在支持跨浏览器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows OS中获取IE,Firefox和Chrome浏览器的浏览器启动/启动事件? - how to get the browser start/launch event for IE , Firefox and Chrome browsers in windows os? 如何在Firefox中使下拉菜单与Chrome / IE相同? - How do I make a dropdown in Firefox look the same as Chrome/IE? 如何使用TypeScript for IE11 / Edge / Chrome / Firefox编译Web组件? - How can I get Web Components to compile with TypeScript for IE11/Edge/Chrome/Firefox? 测试浏览器(Firefox,Chrome,IE)和HSTS - Testing browsers (Firefox, Chrome, IE) and HSTS 为所有浏览器(IE,Chrome,Firefox)的所有浏览器扩展创建单个安装程序 - Create single Installer for all browser extension for all there browsers (IE, Chrome, Firefox) 如何在Angular 4中选择带有chrome之类的文件(如Firefox) - How can i select same file with chrome like firefox in Angular 4 在所有现代浏览器中获得相同的阴影(IE 9除外) - Get the same shadow in all modern browsers (except IE version 9) 居中对齐在除Chrome和Firefox之外的所有浏览器中均可使用 - Center Align Working in all Browsers but Chrome and Firefox javascript如何在FireFox中完美地工作,而在其他浏览器中却根本不工作? - How can javascript work perfectly in FireFox, but not work at all in other browsers? 如何从 Chrome 和 Firefox 获取打开页面的 URL? - How can I get URLs of open pages from Chrome and Firefox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM