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 glossaryButton = `.lmt__glossary_onOffSwitch_label`;
|
||||
|
||||
module.exports = {
|
||||
translate: async (sentence, sourceLanguage = 'auto', targetLanguage) => {
|
||||
if(!/^(auto|[a-z]{2})$/.test(sourceLanguage))
|
||||
|
|
@ -84,7 +86,6 @@ module.exports = {
|
|||
return _res;
|
||||
},
|
||||
clearGlossary: async () => {
|
||||
const glossaryButton = `.lmt__glossary_onOffSwitch_label`;
|
||||
const page = await getNewPage();
|
||||
await page.goto(homepage);
|
||||
await page.waitForSelector(glossaryButton, { visible: true });
|
||||
|
|
@ -98,8 +99,8 @@ module.exports = {
|
|||
setGlossary: async (glossary, sourceLanguage, targetLanguage) => {
|
||||
sourceLanguage = sourceLanguage.toUpperCase();
|
||||
targetLanguage = targetLanguage.toUpperCase();
|
||||
|
||||
const
|
||||
glossaryButton = `.lmt__glossary_onOffSwitch_label`,
|
||||
langSelect = `.lmt__glossary_newEntry_langButton`,
|
||||
sourceGlossaryInput = `.lmt__glossary_newEntry_inputSource`,
|
||||
targetGlossaryInput = `.lmt__glossary_newEntry_inputTarget`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue