0

I am new to selenium. I am doing cross browser testing using 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.

Most of my test scripts are depending on innertext property.

Is there any way (common converter) to get same innertext property value in all browsers?

If I use Selenium to test my application in all browsers. 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

Raj Discussion
  • 165
  • 2
  • 2
  • 8
  • Nothing to do with Selenium or CodedUI surely, but down to how the browser returns `innerText`?! – Arran Nov 05 '14 at 12:38

1 Answers1

0

innerText is old way of using with Internet Explorer. Instead you can use 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

Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54
  • Hi Rahul, Thanks for quick reply. Can you share more information about domElement. I know only CUIT i.e UITestControl. But there is no textContent property on UITestControl. – Raj Discussion Nov 05 '14 at 07:09
  • domElement is element present on web page/Document which we can get by document.getElementbyId. Please check I've edited my answer. – Rahul Nikate Nov 05 '14 at 07:14
  • Hi Rahul, I have already developed few testing using innerText property. What is exact difference between innerText and TextContent property. Is there way to get textContext property value from innerText property value or viceversa – Raj Discussion Nov 06 '14 at 15:49
  • @RajDiscussion Internet explorer use innerText property and Firefox use textContent property. So modify your code like var output = domElement.textContent || domElement.innerText;. So it will work with cross browsers. – Rahul Nikate Nov 07 '14 at 05:12