Skip to content

Commit 281d643

Browse files
committed
Bugfixes on issue #7
1 parent ac2a476 commit 281d643

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.2.9 (2016.03.06)
2+
3+
* Bugfixes on issue #7
4+
15
### 1.2.8 (2016.01.31)
26

37
* Bugfixes on issue #6

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ That's it! Thank you for your contribution!
101101

102102
License
103103
-
104-
Copyright (c) 2015-2016 Richard Huang.
104+
Copyright (c) 2015, 2016 Richard Huang.
105105

106106
This browser extension is free software, licensed under: [GNU Affero General Public License (AGPL-3.0)](http://www.gnu.org/licenses/agpl-3.0.en.html).
107107

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const TEMPLATES = 'templates/';
1919
var packagejson = require('./package.json');
2020
var banner = ['/*',
2121
' Selenium Page Object Generator - to improve agile testing process velocity.',
22-
' Copyright (C) 2015-2016 ' + packagejson.author,
22+
' Copyright (c) 2015, 2016 ' + packagejson.author,
2323
'',
2424
' This program is free software: you can redistribute it and/or modify',
2525
' it under the terms of the GNU Affero General Public License as',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-page-object-generator",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "A nimble and flexible Selenium Page Object Model generator to improve agile testing process velocity.",
55
"dependencies": {
66
"argparse": "^1.0.4",

src/common/generator.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ window.POG=(function() {
1414
var value = node.getAttribute(name);
1515

1616
if (value) {
17-
var selector = node.nodeName.toLowerCase() + '[' + name + '=\'' + value + '\']';
17+
var selector = node.nodeName.toLowerCase();
18+
if (name === 'class') {
19+
selector += '.' + value.split(/\s+/g).join('.');
20+
}
21+
else {
22+
selector += '[' + name + '=\'' + value + '\']';
23+
}
1824
if (document.querySelectorAll(selector).length === 1) {
1925
response = selector;
2026
}
@@ -373,7 +379,7 @@ window.POG=(function() {
373379
var clonedNode = clonedParentNode.querySelector(
374380
node.nodeName.toLowerCase());
375381
clonedNode.parentNode.removeChild(clonedNode);
376-
sanitizeNode(clonedParentNode, parentNode);
382+
clonedParentNode = sanitizeNode(clonedParentNode, parentNode);
377383

378384
text = clonedParentNode.textContent || clonedParentNode.innerText || '';
379385
text = getSentences(text.trim())[0] || '';
@@ -390,12 +396,12 @@ window.POG=(function() {
390396
function getPageVisibleHTML(original) {
391397
original = original || document.body;
392398
var cloned = original.cloneNode(true);
393-
sanitizeNode(cloned, original);
399+
cloned = sanitizeNode(cloned, original);
394400
return cloned.outerHTML;
395401
}
396402

397403
function getSanitizedText(text, max) {
398-
var texts = text.split(/\s+/g);
404+
var texts = (text || '').split(/\s+/g);
399405

400406
if (max) {
401407
texts = texts.slice(0, max);
@@ -523,7 +529,14 @@ window.POG=(function() {
523529
var hiddens = getHiddens(clonedNode, originalNode);
524530
removeNodes(comments);
525531
removeNodes(excludes);
532+
var excludedNode = clonedNode.cloneNode(true);
526533
removeNodes(hiddens);
534+
// ng:view template doesn't have height,
535+
// hence it will considered as hidden
536+
if (clonedNode.textContent.trim() === '') {
537+
clonedNode = excludedNode;
538+
}
539+
return clonedNode;
527540
}
528541

529542
function setDefinitions(input) {
@@ -835,7 +848,7 @@ window.POG=(function() {
835848
var sentences = getSentences(sourceText);
836849
var words = getWordFrequency(sourceText);
837850
sentences = getSentenceFrequency(sentences, words);
838-
var sentence = sentences[0];
851+
var sentence = sentences[0] || '';
839852

840853
// !robot
841854
if (input.attributes.letter !== LETTERS.LOWER && input.attributes.indent !== 1 &&
@@ -862,7 +875,7 @@ window.POG=(function() {
862875

863876
if (input.operations.extras['verify.url']) {
864877
// it's better to generate more information than less
865-
var uri = document.location.href.replace(document.location.origin, '');
878+
var uri = location.href.replace(document.location.origin, '');
866879

867880
var buffer = {
868881
attribute: {

0 commit comments

Comments
 (0)