Add glossary methods #4
1 changed files with 3 additions and 2 deletions
5
index.js
5
index.js
|
|
@ -11,6 +11,8 @@ const getBrowser = async () => {
|
||||||
|
|
||||||
const getNewPage = async () => await (await getBrowser()).newPage();
|
const getNewPage = async () => await (await getBrowser()).newPage();
|
||||||
|
|
||||||
|
const glossaryButton = `.lmt__glossary_onOffSwitch_label`;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
translate: async (sentence, sourceLanguage = 'auto', targetLanguage) => {
|
translate: async (sentence, sourceLanguage = 'auto', targetLanguage) => {
|
||||||
if(!/^(auto|[a-z]{2})$/.test(sourceLanguage))
|
if(!/^(auto|[a-z]{2})$/.test(sourceLanguage))
|
||||||
|
|
@ -84,7 +86,6 @@ module.exports = {
|
||||||
return _res;
|
return _res;
|
||||||
},
|
},
|
||||||
clearGlossary: async () => {
|
clearGlossary: async () => {
|
||||||
const glossaryButton = `.lmt__glossary_onOffSwitch_label`;
|
|
||||||
const page = await getNewPage();
|
const page = await getNewPage();
|
||||||
await page.goto(homepage);
|
await page.goto(homepage);
|
||||||
await page.waitForSelector(glossaryButton, { visible: true });
|
await page.waitForSelector(glossaryButton, { visible: true });
|
||||||
|
|
@ -98,8 +99,8 @@ module.exports = {
|
||||||
setGlossary: async (glossary, sourceLanguage, targetLanguage) => {
|
setGlossary: async (glossary, sourceLanguage, targetLanguage) => {
|
||||||
sourceLanguage = sourceLanguage.toUpperCase();
|
sourceLanguage = sourceLanguage.toUpperCase();
|
||||||
targetLanguage = targetLanguage.toUpperCase();
|
targetLanguage = targetLanguage.toUpperCase();
|
||||||
|
|
||||||
const
|
const
|
||||||
glossaryButton = `.lmt__glossary_onOffSwitch_label`,
|
|
||||||
langSelect = `.lmt__glossary_newEntry_langButton`,
|
langSelect = `.lmt__glossary_newEntry_langButton`,
|
||||||
sourceGlossaryInput = `.lmt__glossary_newEntry_inputSource`,
|
sourceGlossaryInput = `.lmt__glossary_newEntry_inputSource`,
|
||||||
targetGlossaryInput = `.lmt__glossary_newEntry_inputTarget`,
|
targetGlossaryInput = `.lmt__glossary_newEntry_inputTarget`,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue