+
+
+
+
+
Default Snippet has been changed to
+
+
+
+
+
+
+
+
+
+ LetXPath gives you the following meta-data
+
+
1. Locator Value - ${lc}
+
2. Variable Name - ${vn}
+
3. Method Name - ${mn}
+
+ Customize as per your requirements
+
+
Example:
+
+
+
+
+
private ${vn} = ${lc};
+async clickOn${mn}(){
+ await this.click(this.${vn})
+}
+
+
Protractor JS/TS - Result
+
+
private login = element(by.id('loginId'));
+async clickOnLogin(){
+ await this.click(this.login)
+}
+
+
+
+
+
+
+
+
${lc} private WebElement ${vn};
+public void clickOn${mn}(){
+ this.click(this.${vn})
+}
+
+
Selenium JAVA/POM - Result
+
+
@FindBy(id= "loginId") private WebElement login;
+public void clickOnLogin(){
+ this.click(this.login);
+}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/panelconfig.js b/panelconfig.js
index 0024166..99ca8da 100644
--- a/panelconfig.js
+++ b/panelconfig.js
@@ -35,7 +35,6 @@ $(document).ready(function () {
let range = document.createRange();
copyToClipBoard(range, from);
$('select').prop('selectedIndex', 0);
- // setTimeout(() => { from.classList.add('d-hide') }, 3000)
}, 100);
});
@@ -143,6 +142,12 @@ function generateSnippet(type, codeType, codeValue, vn, mn) {
let code;
let lang = result.langID;
switch (lang) {
+ case "playwrightJS":
+ code = playwrightSnippetJS(type, codeType, codeValue, vn);
+ break;
+ case "playwrightJava":
+ code = playwrightSnippetJava(type, codeType, codeValue, vn);
+ break;
case "javas":
code = javaSnippet(type, codeType, codeValue, vn);
break;
@@ -166,17 +171,13 @@ function generateSnippet(type, codeType, codeValue, vn, mn) {
code = javaSnippet(type, codeType, codeValue, vn);
break;
}
- if (code === 'hide') {
- document.querySelector('.toast').classList.add('d-hide');
- }
- else {
- document.querySelector(".toast").textContent = '';
- document.querySelector('.toast').classList.remove('d-hide');
- // let to = document.querySelector(".toast");
- let t = `
+
+ document.querySelector(".toast").textContent = '';
+ document.querySelector('.toast').classList.remove('d-hide');
+ // let to = document.querySelector(".toast");
+ let t = `
${code}
`
- $('.toast').append(t);
- }
+ $('.toast').append(t);
});
}
function javaSnippet(type, codeType, codeValue, variable) {
@@ -226,6 +227,103 @@ function javaSnippet(type, codeType, codeValue, variable) {
}
return str;
}
+
+function playwrightSnippetJava(type, codeType, codeValue, variable) {
+ let str;
+ switch (codeType) {
+ case "CSS":
+ str = `page.locator("${codeValue}")`;
+ break;
+ case "Unique Class Atrribute":
+ str = `page.locator(".${codeValue}")`;
+ break;
+ case "Unique TagName":
+ str = `page.locator("${codeValue}")`;
+ break;
+ case "Link Text":
+ str = `page.locator("'${codeValue}'")`;
+ break;
+ case "Unique ID":
+ str = `page.locator("id=${codeValue}")`;
+ break;
+ case "Unique Name":
+ str = `page.locator("[name='${codeValue}']")`;
+ break;
+ case "Unique PartialLinkText":
+ str = `page.locator("a:has-text('${codeValue}'")`;
+ break;
+ default:
+ str = `page.locator("${codeValue}")`;
+ break;
+ }
+ switch (type) {
+ case "click":
+ str += `.click();`
+ break;
+ case "sendKeys":
+ str += `.type();`
+ break;
+ case "getAttribute":
+ str += `.getAttribute();`
+ break;
+ case "getText":
+ str += `.textContent();`
+ break;
+ default:
+ str = 'hide';
+ break;
+ }
+ return str;
+}
+
+function playwrightSnippetJS(type, codeType, codeValue, variable) {
+ let str;
+ switch (codeType) {
+ case "CSS":
+ str = `await page.locator("${codeValue}")`;
+ break;
+ case "Unique Class Atrribute":
+ str = `await page.locator(".${codeValue}")`;
+ break;
+ case "Unique TagName":
+ str = `await page.locator("${codeValue}")`;
+ break;
+ case "Link Text":
+ str = `await page.locator("'${codeValue}'")`;
+ break;
+ case "Unique ID":
+ str = `await page.locator("id=${codeValue}")`;
+ break;
+ case "Unique Name":
+ str = `await page.locator("[name='${codeValue}']")`;
+ break;
+ case "Unique PartialLinkText":
+ str = `await page.locator("a:has-text('${codeValue}'")`;
+ break;
+ default:
+ str = `await page.locator("${codeValue}")`;
+ break;
+ }
+ switch (type) {
+ case "click":
+ str += `.click();`
+ break;
+ case "sendKeys":
+ str += `.type();`
+ break;
+ case "getAttribute":
+ str += `.getAttribute();`
+ break;
+ case "getText":
+ str += `.textContent();`
+ break;
+ default:
+ str = 'hide';
+ break;
+ }
+ return str;
+}
+
// TODO: test snippets values
function jsSnippet(type, codeType, codeValue, variable) {
diff --git a/popup/popup.html b/popup/popup.html
index 97ff834..dc34dd2 100644
--- a/popup/popup.html
+++ b/popup/popup.html
@@ -59,7 +59,7 @@
-
+