blob: 93d96284e0befa786c6ea813b711e564f148179d [file] [log] [blame]
<html>
<head>
<title>get_text_test</title>
<script type="text/javascript" src="test_bootstrap.js"></script>
<script type="text/javascript">
goog.require('goog.testing.jsunit');
goog.require('core.text');
goog.require('bot.locators');
</script>
<script type="text/javascript">
function testCopiedFromOriginalSelenium() {
assertTrue(core.text.isTextPresent("Text1"));
assertFalse(core.text.isTextPresent("Text2"));
assertFalse(core.text.isTextPresent("Text3"));
assertFalse(core.text.isTextPresent("Text4"));
assertFalse(core.text.isTextPresent("Text5"));
assertFalse(core.text.isTextPresent("Text6"));
assertFalse(core.text.isTextPresent("Text7"));
assertFalse(core.text.isTextPresent("Text8"));
}
function testExactMatch() {
assertTrue(core.text.isTextPresent("exact:This is a test of"));
}
function testCanSearchByXPath() {
if (!(document.documentElement['selectSingleNode'] || document['evaluate'])) {
// TODO: Remove when all browsers [IE] support xpath
return;
}
assertTrue(core.text.getText('//body').length > 0);
}
function testCanObtainTextDirectlyFromAnElement() {
var element = bot.locators.findElement({id: 'text1'});
assertEquals('Text1', core.text.getText(element));
}
function testHandlesNbspInTextProperly() {
var element = bot.locators.findElement({id: 'theSpan'});
var text = core.text.getText(element);
assertEquals('this is the span', core.text.getText(element));
}
function testCollapsesMultipleNbspsProperly() {
var element = bot.locators.findElement({id: 'spaces'});
var text = core.text.getText(element);
assertEquals('1 space|2 space|3 space|1 nbsp|2 nbsp|3 nbsp|2 space_nbsp|2 nbsp_space|3 space_nbsp_space|3 nbsp_space_nbsp', text);
}
</script>
</head>
<body>
<script type="text/javascript">
var Text8 = '';
</script>
<div>
<span id="text1">Text1</span><br/>
<span style="visibility:hidden">Text2</span><br/>
<span style="display:none">Text3</span><br/>
<span id="theSpan">this is the&nbsp;span</span><br/>
<div id="spaces">
<kbd>1 space|2 space|3 space|1&nbsp;nbsp|2&nbsp;&nbsp;nbsp|3&nbsp;&nbsp;&nbsp;nbsp|2 &nbsp;space_nbsp|2&nbsp; nbsp_space|3 &nbsp; space_nbsp_space|3&nbsp; &nbsp;nbsp_space_nbsp</kbd>
</div>
<div style="visibility:hidden">
<span>Text4</span><br/>
<span style="visibility:hidden">Text5</span><br/>
<span style="display:none">Text6</span><br/>
</div>
<div style="display: none">
<span>Text7</span><br/>
<span style="visibility:hidden">Text8</span><br/>
<span style="display:none">Text9</span><br/>
</div>
<img style="width: 644px; height: 41px;" alt="banner" src="banner.gif"><br>
This is a test of the open command.
</div>
</body>
</html>