Для этого теста приложений, выполняя серию огурцов с проверкой в селене. На шагах мы нажимаем над элементом, который вызывает всплывающее окно для всплывающего окна. Затем предполагается, что Selenium найдет элемент в подсказке инструментов и проверит его отображение. При выполнении этого теста локально тест завершается успешно, но при запуске внутри Docker он приводит к STALEELEMENTEREFERFERROR для всплывающего окна. < /P>
When User hovers over tooltip
Then User sees the tooltip information
< /code>
, который вызывает эти две функции < /p>
hoverOverTooltip() {
return this.hover(locators.Tooltip);
}
verifyTooltipinfoIsDisplayed() {
const locatorToVerify = {
Mode: By.xpath('//span[contains(text(), \'Modes\')]'),
low: By.xpath('//span[contains(text(), \'Low\')]'),
high: By.xpath('//span[contains(text(), \'High\')]'),
medium: By.xpath('//span[contains(text(), \'Medium\')]'),
}
return Promise.all([
this.verifyElementIsDisplayed(locatorToVerify.Mode),
this.verifyElementIsDisplayed(locatorToVerify.low),
this.verifyElementIsDisplayed(locatorToVerify.high),
this.verifyElementIsDisplayedAfterHover(locatorToVerify.medium),
])
}
< /code>
И это проверки селена < /p>
async verifyElementIsDisplayed(locator) {
const element = await this.app.page.findElement(locator);
return element.isDisplayed();
}
async hover(locator) {
const element = await this.app.page.findElement(locator);
const actions = this.page.actions({async: true});
await actions.move({origin: element}).perform();
}
< /code>
Запуск в Docker приводит к ошибке < /p>
✖ Then User sees the tooltip information # file:steps.js:60
StaleElementReferenceError: stale element reference: stale element not found in the current frame
(Session info: chrome=124.0.6367.243)
at Object.throwDecodedError (/tests/node_modules/selenium-webdriver/lib/error.js:523:15)
at parseHttpResponse (/tests/node_modules/selenium-webdriver/lib/http.js:524:13)
at Executor.execute (/tests/node_modules/selenium-webdriver/lib/http.js:456:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Driver.execute (/tests/node_modules/selenium-webdriver/lib/webdriver.js:745:17)
at async SeleniumEditConnectionPage.verifyElementIsDisplayedAfterHover (file
at async CustomWorld. (file)
< /code>
Я попытался написать этот монстр функции, чтобы попытаться повторно включить элемент и повторно-версию по всплеске инструментов, но он не пытается выполнить Action.move, чтобы снова вернуть по элементу и покинуть функцию. < /p>
async verifyElementIsDisplayedAfterHover(locator, hoverLocator) {
try {
await this.verifyElementIsDisplayed(locator);
}
catch (error) {
if (error.name === 'StaleElementReferenceError') {
console.log("StaleElementReferenceError caught");
// Re-locate the hover element
console.log("Re-locating hover element...");
const hoverElement = await this.app.page.findElement(hoverLocator);
// Re-hover
console.log("Re-hovering...");
const actions = this.app.page.actions({ async: true });
console.log("Hover acction made");
await actions.move({ origin: hoverElement, x: 1, y: 1 }).perform();
console.log("Hover action completed");
// Optional: small delay to allow DOM update
await this.app.page.sleep(300); // or use setTimeout in a wrapper
// Wait for the element to appear and be visible
console.log("Waiting for element to be visible...");
await this.app.page.wait(until.elementLocated(locator), 5000);
const element = await this.app.page.findElement(locator);
await this.app.page.wait(until.elementIsVisible(element), 5000);
return element.isDisplayed();
} else
throw new Error(`Unable to find the '${locator}' on the window.\n Returned error: '${error}'`);
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ot-locally
StaleElementReferenceError в селене при запуске в докере, но не на местном уровне ⇐ Javascript
Форум по Javascript
1753154369
Anonymous
Для этого теста приложений, выполняя серию огурцов с проверкой в селене. На шагах мы нажимаем над элементом, который вызывает всплывающее окно для всплывающего окна. Затем предполагается, что Selenium найдет элемент в подсказке инструментов и проверит его отображение. При выполнении этого теста локально тест завершается успешно, но при запуске внутри Docker он приводит к STALEELEMENTEREFERFERROR для всплывающего окна. < /P>
When User hovers over tooltip
Then User sees the tooltip information
< /code>
, который вызывает эти две функции < /p>
hoverOverTooltip() {
return this.hover(locators.Tooltip);
}
verifyTooltipinfoIsDisplayed() {
const locatorToVerify = {
Mode: By.xpath('//span[contains(text(), \'Modes\')]'),
low: By.xpath('//span[contains(text(), \'Low\')]'),
high: By.xpath('//span[contains(text(), \'High\')]'),
medium: By.xpath('//span[contains(text(), \'Medium\')]'),
}
return Promise.all([
this.verifyElementIsDisplayed(locatorToVerify.Mode),
this.verifyElementIsDisplayed(locatorToVerify.low),
this.verifyElementIsDisplayed(locatorToVerify.high),
this.verifyElementIsDisplayedAfterHover(locatorToVerify.medium),
])
}
< /code>
И это проверки селена < /p>
async verifyElementIsDisplayed(locator) {
const element = await this.app.page.findElement(locator);
return element.isDisplayed();
}
async hover(locator) {
const element = await this.app.page.findElement(locator);
const actions = this.page.actions({async: true});
await actions.move({origin: element}).perform();
}
< /code>
Запуск в Docker приводит к ошибке < /p>
✖ Then User sees the tooltip information # file:steps.js:60
StaleElementReferenceError: stale element reference: stale element not found in the current frame
(Session info: chrome=124.0.6367.243)
at Object.throwDecodedError (/tests/node_modules/selenium-webdriver/lib/error.js:523:15)
at parseHttpResponse (/tests/node_modules/selenium-webdriver/lib/http.js:524:13)
at Executor.execute (/tests/node_modules/selenium-webdriver/lib/http.js:456:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Driver.execute (/tests/node_modules/selenium-webdriver/lib/webdriver.js:745:17)
at async SeleniumEditConnectionPage.verifyElementIsDisplayedAfterHover (file
at async CustomWorld. (file)
< /code>
Я попытался написать этот монстр функции, чтобы попытаться повторно включить элемент и повторно-версию по всплеске инструментов, но он не пытается выполнить Action.move, чтобы снова вернуть по элементу и покинуть функцию. < /p>
async verifyElementIsDisplayedAfterHover(locator, hoverLocator) {
try {
await this.verifyElementIsDisplayed(locator);
}
catch (error) {
if (error.name === 'StaleElementReferenceError') {
console.log("StaleElementReferenceError caught");
// Re-locate the hover element
console.log("Re-locating hover element...");
const hoverElement = await this.app.page.findElement(hoverLocator);
// Re-hover
console.log("Re-hovering...");
const actions = this.app.page.actions({ async: true });
console.log("Hover acction made");
await actions.move({ origin: hoverElement, x: 1, y: 1 }).perform();
console.log("Hover action completed");
// Optional: small delay to allow DOM update
await this.app.page.sleep(300); // or use setTimeout in a wrapper
// Wait for the element to appear and be visible
console.log("Waiting for element to be visible...");
await this.app.page.wait(until.elementLocated(locator), 5000);
const element = await this.app.page.findElement(locator);
await this.app.page.wait(until.elementIsVisible(element), 5000);
return element.isDisplayed();
} else
throw new Error(`Unable to find the '${locator}' on the window.\n Returned error: '${error}'`);
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79709831/staleelementreferenceerror-in-selenium-when-running-in-docker-but-not-locally[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия