-
-
-
-
-
-
Code snippet
-
Configuration
-
-
-
-
-
-
- Choose an option
- Playwright - Node
- Selenium Java
- Selenium Python
- Selenium C#
- Protractor
- Custom Framework
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/option/option.js b/option/option.js
index 0d931b6..6130532 100644
--- a/option/option.js
+++ b/option/option.js
@@ -6,13 +6,14 @@ $(document).ready(function () {
embedCodeSample(codeType);
setStorage({ langID: codeType });
}
- if (result.customLang != undefined) {
+ else if (result.customLang != undefined) {
const codeType = result.customLang;
$("select").val(codeType).change();
embedCodeSample(codeType);
setStorage({ langID: codeType });
} else {
- $("select").val(result.langID).change();
+ // $("select").val(result.langID).change();
+ embedCodeSample('javas');
setStorage({ langID: 'javas' });
}
// set edited values in textarea
diff --git a/panel/panel.js b/panel/panel.js
index 505f07c..ce0c5fa 100644
--- a/panel/panel.js
+++ b/panel/panel.js
@@ -1,17 +1,292 @@
chrome.runtime.onMessage.addListener((req, rec, res) => {
- console.log(req);
- if (req.request === "sendtodevtools") {
- buildUI(req.xpath);
- }
+ document.querySelector('.toast').classList.add('d-hide');
+ switch (req.request) {
+ // case "pageInfo":
+ // console.log(req.request);
+ // try {
+ // let ui = `
+ //
+ // Page Title
+ // ${req.tab.title}
+ //
+ //
+ // Page URL
+ // ${req.tab.url}
+ //
+ //
`;
+ // jQuery('#eleInfo').empty();
+ // jQuery('#eleInfo').append(ui);
+ // } catch (error) { }
+ // return true;
+
+ case "send_to_dev":
+ buildUI(req);
+ document.getElementById("cssbadge").attributes.getNamedItem('data-badge').value = '0'
+ if (req.cssPath.length > 0) {
+ buildCSSUI(req)
+ } else {
+ jQuery("#cssbody").empty();
+ let ui = `
+
Please select any element to get CSS/XPath
+
more new patterns coming soon :)
+
Did you know LetXPath is an open-source, if you found something wrong fix it :)
+
`;
+ jQuery("#cssbody").append(ui);
+ }
+ if (req.xpathid.length == 0) {
+ jQuery("#addXPath").empty();
+ let ui = `
+
Please select any element to get XPath/CSS
+
more new patterns coming soon :)
+
Did you know LetXPath is an open-source, if you found something wrong fix it :)
+
`;
+ jQuery("#addXPath").append(ui);
+ }
+ return true;
+ case "anchor":
+ document.getElementById("xpbadge").attributes.getNamedItem('data-badge').value = 0;
+ jQuery("#addXPath").empty();
+ document.getElementById("cssbadge").attributes.getNamedItem('data-badge').value = 0;
+ jQuery("#cssbody").empty();
+ let ui = `
+
Please select any element to get XPath/CSS
+
more new patterns coming soon :)
+
Did you know LetXPath is an open-source, if you found something wrong fix it :)
+
`;
+ jQuery("#addXPath").append(ui);
+ jQuery("#cssbody").append(ui);
+ generateAxes(req);
+ return true;
+ case "axes":
+ $("#anxp").empty();
+ $("#anxp").text(req.data);
+ return true;
+ case "fromUtilsSelector":
+ utilsLocatorUI(req.data);
+ return true;
+ case "customSearchResult":
+ buildSearchUI(req.data);
+ default:
+ return true;
+ }
})
+let devtools_connections = chrome.runtime.connect({ name: "ortoni_devtools_message" });
-function buildUI(data) {
- // document.write(data);
- chrome.storage.local.get(["len"], (data) => {
- // document.write(data.len);
- let display = document.getElementById("display");
- display.textContent = '';
- display.textContent = data.len;
+function buildSearchUI(data) {
+ jQuery("#insertsearch").empty();
+ let ui = `
${data.count}
+
${data.xpath} `;
+ $("#insertsearch").append(ui);
+}
- })
+function utilsLocatorUI(data) {
+ let len = data.length;
+ if (len > 0) {
+ let ui = `
+
+
+ Select
+ Name
+ XPath
+
+
+ ${getTR()}
+
+
`;
+ $("#show").append(ui);
+ }
+ function getTR() {
+ let tr = '';
+ for (let i = 0; i < data.length; i++) {
+ tr += `
+ ${data[i][1]}
+ ${data[i][2][0][2]} `;
+ }
+ return tr;
+ }
+}
+// generate axes based on user inputs
+function generateAxes(req) {
+ // Bring the panel to active
+ $('#tab_header li.tab-item').removeClass('active');
+ $("#tab_header li.tab-item[data-option='3']").addClass('active');
+ $('#tab_container .container_item').removeClass('active');
+ $('div[data-item="3"]').addClass('active');
+ jQuery("#anchorXPath").empty();
+ let ui = `
+
+
+
Parent Element
+ ${sourceElement(req.data.src)}
+
+
+
+
Child Element
+ ${targetElement(req.data.dst)}
+
+
`
+ jQuery("#anchorXPath").append(ui);
+}
+// Build the source element
+function sourceElement(element) {
+ let ui = '';
+ for (let i = 0; i < element.length; i++) {
+ if (i == 0) {
+ ui += `
+
+
+ ${i + 1}. ${element[i][2]}
+
+
`
+ } else {
+ ui += `
+
+
+ ${i + 1}. ${element[i][2]}
+
+
`;
+ }
+ }
+ return ui;
+}
+// Build the target element
+function targetElement(element) {
+ let ui = '';
+ for (let i = 0; i < element.length; i++) {
+ if (i == 0) {
+ ui += `
+
+
+ ${i + 1}. ${element[i][2]}
+
+
`
+ } else {
+ ui += `
+
+
+ ${i + 1}. ${element[i][2]}
+
+
`;
+ }
+ }
+ return ui;
+}
+// -------- based on the snippet type show the code ----------
+function buildUI(data) {
+ jQuery("#addXPath").empty();
+ if (data.webtabledetails != null) {
+ let table = `
`;
+ jQuery("#addXPath").append(table);
+ }
+ let len = data.xpathid;
+ document.getElementById("xpbadge").attributes.getNamedItem('data-badge').value = len.length
+ for (let i = 0; i < len.length; i++) {
+ generateXPathUI(data, i);
+ }
+}
+// -------- Build XPath UI ---------
+function generateXPathUI(data, i) {
+ let ui = `
`;
+ jQuery("#addXPath").append(ui);
+}
+// ------- build drop-down for snippet based on element type -------
+function getSelectionValues(data, i, xp, isCSS) {
+ // let xp = data.xpathid;
+ let finalOP;
+ let t = '';
+ if (isCSS) {
+ t = 'CSS';
+ } else {
+ t = xp[i][1]
+ }
+ let type = data.type;
+ let tag = data.tag;
+ switch (tag) {
+ case "textarea":
+ finalOP = `
Snippet
+
sendKeys
+
getAttribute `
+ break;
+ case "input":
+ if (type === "submit" || type === "radio" || type === "checkbox") {
+ finalOP = `
Snippet
+
click
+
getAttribute `
+ } else {
+ finalOP = `
Snippet
+
sendKeys
+
getAttribute `
+ }
+ break;
+ case "img":
+ finalOP = `
Snippet
+
click
+
getAttribute `
+ break;
+ default:
+ finalOP = `
Snippet
+
click
+
getText `
+ break;
+ }
+ return finalOP;
+}
+function buildCSSUI(data) {
+ document.getElementById("cssbadge").attributes.getNamedItem('data-badge').value = data.cssPath.length
+ jQuery("#cssbody").empty();
+ let ui = '';
+ for (let i = 0; i < data.cssPath.length; i++) {
+ ui += `
`;
+ }
+ jQuery("#cssbody").append(ui)
}
\ No newline at end of file
diff --git a/panelconfig.js b/panelconfig.js
index 99ca8da..e3641c8 100644
--- a/panelconfig.js
+++ b/panelconfig.js
@@ -382,28 +382,28 @@ function pySnippet(type, codeType, codeValue, variable) {
// getAttribute Collection based XPath //input[@placeholder='first name & last name'] firstName" false
switch (codeType) {
case "CSS":
- str = `find_element_by_css_selector("${codeValue}")`;
+ str = `driver.find_element(by=By.CSS_SELECTOR, value="${codeValue}")`;
break;
case "Unique Class Atrribute":
- str = `find_element_by_class_name("${codeValue}")`;
+ str = `driver.find_element(by=By.CLASS_NAME, value="${codeValue}")`;
break;
case "Unique TagName":
- str = `find_element_by_tag_name("${codeValue}")`;
+ str = `driver.find_element(by=By.TAG_NAME, value="${codeValue}")`;
break;
case "Link Text":
- str = `find_element_by_link_text("${codeValue}")`;
+ str = `driver.find_element(by=By.LINK_TEXT, value="${codeValue}")`;
break;
case "Unique ID":
- str = `find_element_by_id("${codeValue}")`;
+ str = `driver.find_element(by=By.ID, value="${codeValue}")`;
break;
case "Unique Name":
- str = `find_element_by_name("${codeValue}")`;
+ str = `driver.find_element(by=By.NAME, value="${codeValue}")`;
break;
case "Unique PartialLinkText":
- str = `find_element_by_partial_link_text("${codeValue}")`;
+ str = `driver.find_element(by=By.PARTIAL_LINK_TEXT, value="${codeValue}")`;
break;
default:
- str = `find_element_by_xpath("${codeValue}")`;
+ str = `driver.find_element(by=By.XPATH, value="${codeValue}")`;
break;
}
switch (type) {