Skip to content

Commit

Permalink
Bugfixes on invalid variable name.
Browse files Browse the repository at this point in the history
  • Loading branch information
rickypc committed Feb 1, 2016
1 parent 1a64b58 commit ac2a476
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 30 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.2.8 (2016.01.31)

* Bugfixes on issue #6

### 1.2.7 (2016.01.19)

* Update copyright year
Expand All @@ -14,7 +18,7 @@

### 1.2.5 (2015.09.22)

* Bugfixes
* Bugfixes on issue #3

### 1.2.4 (2015.08.28)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selenium-page-object-generator",
"version": "1.2.7",
"version": "1.2.8",
"description": "A nimble and flexible Selenium Page Object Model generator to improve agile testing process velocity.",
"dependencies": {
"argparse": "^1.0.4",
Expand Down
14 changes: 14 additions & 0 deletions specs/issues/006.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label id="LS1.0Q1.0" for="S1.0Q1.0" class="LC1"><b>1.1</b> What is the legal name of your Company?</label><br/>
<input id="S1.0Q1.0" name="S1.0Q1.0" class="Answered" value="11b" required type="text"/>
<!--
[FindsBy(How = How.Id, Using = "S1.0Q1.0")]
[CacheLookup]
private IWebElement 11WhatIsTheLegalName;
-->
</body>
</html>
69 changes: 41 additions & 28 deletions src/common/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ window.POG=(function() {
currentSelector += '[type=\'' + node.type + '\']';
}
else if (node.getAttribute('data-type')) {
currentSelector += '[data-type=\'' + node.getAttribute('data-type') + '\']';
currentSelector += '[data-type=\'' +
node.getAttribute('data-type') + '\']';
}
}
}
Expand Down Expand Up @@ -134,7 +135,7 @@ window.POG=(function() {
buffer.operation.documentation = input.action + suffixes.action +
suffixes.documentation;
buffer.operation.name = getLetter(input.action + suffixes.name,
input.letters.operation);
input.letters.operation, input.action);

return buffer;
}
Expand All @@ -147,12 +148,11 @@ window.POG=(function() {
var clones = cloned.getElementsByTagName('*');
var originals = original.getElementsByTagName('*');
var hiddens = (cloned) ? Array.filter(cloned.querySelectorAll(
'*:not(br):not(img):not(input):not(link):not(option):not(script):not(select):not(style)'),
function(item, index) {
var sourceIndex = [].indexOf.call(clones, item);
return originals[sourceIndex].offsetHeight < 1 ||
!isElementInViewport(item);
}) : [];
'*:not(br):not(img):not(input):not(link):not(option):not(script):not(select):not(style)'
), function(item, index) {
var sourceIndex = [].indexOf.call(clones, item);
return originals[sourceIndex].offsetHeight < 1 || !isElementInViewport(item);
}) : [];
return hiddens;
}

Expand Down Expand Up @@ -214,33 +214,42 @@ window.POG=(function() {
return text;
}

function getLetter(value, type) {
function getLetter(value, type, action) {
action = action || '';
type = type || LETTERS.CAMEL;
type = parseInt(type);
value = value || '';

if (type !== LETTERS.NATURAL) {
// move number prefix to the end of the value
var oldValue = value.replace(action, '').trim();
var numberPrefix = /^([\d.]+)/.exec(oldValue);
if (numberPrefix) {
value = value.replace(numberPrefix[0], '') + ' ' + numberPrefix[0];
}
}

switch (type) {
case LETTERS.LOWER:
case LETTERS.UPPER:
value = value.replace(/\./g, '_').replace(/\s+|__/g, '_').replace(/^_|_$/g, '');
value = (type === LETTERS.LOWER) ? value.toLowerCase() : value.toUpperCase();
break;
case LETTERS.CAMEL:
case LETTERS.NATURAL:
case LETTERS.PROPER:
value = value.replace(/\./g, ' ').trim().replace(/\s\s+/g, ' ').
replace(/\w\S*/g, function(word) {
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
});

if (type === LETTERS.CAMEL || type === LETTERS.PROPER) {
value = value.replace(/\s+/g, '');

if (type === LETTERS.CAMEL) {
value = value.charAt(0).toLowerCase() + value.substr(1);
}
}).replace(/\s+/g, '');
if (type === LETTERS.CAMEL) {
value = value.charAt(0).toLowerCase() + value.substr(1);
}
break;
case LETTERS.NATURAL:
value = value.trim().replace(/\s\s+/g, ' ').replace(/\w\S*/g, function(word) {
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
});
break;
}

return value;
Expand Down Expand Up @@ -438,7 +447,9 @@ window.POG=(function() {
}

// desc
sentences.sort(function(a, b) { return sentences.frequencies[b] - sentences.frequencies[a]; });
sentences.sort(function(a, b) {
return sentences.frequencies[b] - sentences.frequencies[a];
});

return sentences;
}
Expand All @@ -450,11 +461,12 @@ window.POG=(function() {
words.frequencies = {};
words.tops = [];

text.toLowerCase().split(/[\s*\.*\,\;\+?\#\|:\-\/\\\[\]\(\)\{\}$%&0-9*]/).map(function(k, v) {
if (k && k.length > 1) {
words.frequencies[k]++ || (words.frequencies[k] = 1);
}
});
text.toLowerCase().split(/[\s*\.*\,\;\+?\#\|:\-\/\\\[\]\(\)\{\}$%&0-9*]/).
map(function(k, v) {
if (k && k.length > 1) {
words.frequencies[k]++ || (words.frequencies[k] = 1);
}
});

for (var word in words.frequencies) {
words[++index] = word;
Expand Down Expand Up @@ -588,10 +600,11 @@ window.POG=(function() {
submit.label = label;
submit.text = text;
}
else if (submit.text === '' && text.toLowerCase().indexOf('submit') > -1) {
submit.label = label;
submit.text = text;
}
else if (submit.text === '' && text.toLowerCase().
indexOf('submit') > -1) {
submit.label = label;
submit.text = text;
}
}
else {
if (inputType === 'hidden') {
Expand Down

0 comments on commit ac2a476

Please sign in to comment.