Skip to content

Commit

Permalink
merge rules
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanIovlev authored and anisa07 committed Apr 1, 2018
1 parent c8ee82a commit c535cde
Show file tree
Hide file tree
Showing 6 changed files with 649 additions and 21,895 deletions.
118 changes: 24 additions & 94 deletions app/data/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,104 +113,34 @@ ElementFields.set("DynamicTable", {
});*/

let SimpleRules = {
"Button": [{
"Locator": "button[type=submit]",
"uniqness": "text",
"id": 0
}],
"CheckBox": [{
"Locator": "input[type=checkbox]",
"id": 0,
"uniqness": "id"
}],
"Image": [{
"Locator": "img",
"id": 0,
"uniqness": "id"
}],
"Label": [{
"Locator": "h1",
"id": 0,
"uniqness": "name"
},
{
"Locator": "h2",
"id": 1,
"uniqness": "name"
},
{
"Locator": "h3",
"id": 2,
"uniqness": "name"
},
{
"Locator": "[ui=label]",
"id": 3,
"uniqness": "text"
}
"Button": [{ "Locator": "button[type=submit]", "uniqness": "text", "id": 0}],
"CheckBox": [{"Locator": "input[type=checkbox]", "id": 0, "uniqness": "name"}],
"Image": [{"Locator": "img", "id": 0, "uniqness": "id"}],
"Label": [{"Locator": "h1", "id": 0, "uniqness": "name"},
{"Locator": "h2", "id": 1, "uniqness": "name"},
{"Locator": "h3", "id": 2, "uniqness": "name"},
{"Locator": "[ui=label]", "id": 3, "uniqness": "text"}
],
"Link": [{ Locator: "", uniqness: "", id: 0 }],
"Text": [{
"Locator": ".main-txt",
"id": 0,
"uniqness": "name"
}],
"TextField": [{
"Locator": "input[type=text]",
"id": 0,
"uniqness": "id"
},
{
"Locator": "input[type=password]",
"id": 1,
"uniqness": "id"
}
"Link": [{"Locator": "", "uniqness": "", id: 0 }],
"Text": [{"Locator": ".main-txt", "id": 0, "uniqness": "name"}],
"TextField": [{"Locator": "input[type=text]", "id": 0, "uniqness": "id"},
{"Locator": "input[type=password]", "id": 1, "uniqness": "id"}
],
"TextArea": [{
"Locator": "textarea",
"id": 0,
"uniqness": "id"
}],
"DataPicker": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"FileInput": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"Selector": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"CheckList": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"Menu": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"RadioButtons": [{
"Locator": "",
"id": 0,
"uniqness": ""
}],
"Tabs": [{
"Locator": "",
"id": 0,
"uniqness": ""
}]
"TextArea": [{"Locator": "textarea", "id": 0, "uniqness": "id"}],
"DataPicker": [{"Locator": "", "id": 0, "uniqness": ""}],
"FileInput": [{"Locator": "", "id": 0, "uniqness": ""}],
"Selector": [{"Locator": "", "id": 0, "uniqness": ""}],
"CheckList": [{"Locator": "", "id": 0, "uniqness": ""}],
"Menu": [{"Locator": "", "id": 0, "uniqness": ""}],
"RadioButtons": [{"Locator": "", "id": 0, "uniqness": ""}],
"Tabs": [{"Locator": "", "id": 0, "uniqness": ""}]
};
let ComplexRules = {
"Dropdown": [{ Root: "[jtype=dropdown] button", uniqness: ".filter-option#text", Value: "", List: "li", Expand: ".caret", id: 0 }],
"ComboBox": [{ Root: "[jtype=combobox] button", uniqness: ".filter-option#text", Value: "", List: "li", Expand: ".caret", id: 0 }],
"DropList": [{ Root: "[jtype=droplist] button", uniqness: ".filter-option#text", Value: "", List: "li", Expand: ".caret", id: 0 }],
"Dropdown": [{ Root: "div[ui=dropdown]", uniqness: "id", Value: ".filter-option", List: "li", Expand: ".caret", id: 0 },
{ Root: "select[ui=dropdown]", uniqness: "id", Value: "", List: "", Expand: "", id: 1 }],
"ComboBox": [{ Root: "div[ui=combobox]", uniqness: "id", Value: "input", List: "li", Expand: ".caret", id: 0 },
{ Root: "select[ui=combobox]", uniqness: "id", Value: "", List: "", Expand: "", id: 1 }],
"DropList": [{ Root: "div[ui=droplist]", uniqness: "id", Value: "button", List: "li", Expand: ".caret", IsSelected: "././/input", id: 0 }],
"Table": [{
Root: "table", Header: "", RowHeader: "", Cell: "",
Column: "", Row: "", Footer: "", id: 0, uniqness: 'class'
Expand Down
21 changes: 18 additions & 3 deletions app/reducers/POgen/genPo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,37 @@ export let genEl = (obj) => {
chrome.devtools.inspectedWindow.eval('document.location', (r, err) => {
page.url = r.pathname;
objCopy.SiteInfo.hostName = r.hostname;
page.title = r.pathname.split("/").pop().replace(/\.html|\.htm/, '');
objCopy.SiteInfo.siteTitle = toName(r.hostname.substring(0,r.hostname.lastIndexOf(".")));
objCopy.SiteInfo.origin = r.origin;
});

chrome.devtools.inspectedWindow.eval('document.domain', (r, err) => {
if (r !== "") {
objCopy.SiteInfo.domainName = r;
objCopy.SiteInfo.domainName = r
objCopy.SiteInfo.pack = r.split('.').reverse().join('.');
}
});

chrome.devtools.inspectedWindow.eval('document.title', (r, err) => {
if (r !== "") {
page.name = r;
page.title = r;
page.name = toName(r);
}
});

function toName(n) {
let name = [];
if (n) {
//[^a-zA-Zа-яёА-ЯЁ0-9]
let arrayName = n.split(/[^a-zA-Zа-яёА-ЯЁ0-9]/);
for (let j = 0; j < arrayName.length; j++) {
if (arrayName[j]) {
name.push(arrayName[j][0].toUpperCase() + arrayName[j].slice(1));
}
}
}
return name.join(" ");
}
chrome.devtools.inspectedWindow.eval(
'document.body.outerHTML', (r, err) => {
if (err) {
Expand Down Expand Up @@ -189,6 +203,7 @@ export let genEl = (obj) => {
}
fillEl(e, t, parent, ruleId);
};
let tooMuchElements = `Too much elements found(${elements.length} for ${uniqness.value}. Locator (${firstSearch.locatorType.locator}))`;
if (elements.length > 1) {
if (uniqness.value === "tag" || uniqness.value === '[') {
addToLog(`Warning! Too much elements found by locator ${firstSearch.locatorType.locator}; uniqness ${uniqness.value}; ${elements.length} elements`);
Expand Down
Loading

0 comments on commit c535cde

Please sign in to comment.