Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
log list elements
Browse files Browse the repository at this point in the history
  • Loading branch information
odalys-dataport committed Jun 11, 2024
1 parent f8cc566 commit fcd4f71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion page-objects/pages/NavigationLeftPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async function areSubMenuItemsVisible(listOfExpectedSubItems) {
return item.trim();
});
const listOfSubItems = await getListOfSubItems();
console.log('pampelmuse', listOfSubItems);
// console.log('pampelmuse', listOfSubItems);
const isSame =
listOfExpectedSubItems.length == listOfSubItems.length &&
listOfSubItems.every(function (element, index) {
Expand Down
35 changes: 19 additions & 16 deletions runtime/helpers/elementHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const waitHelpers = require('./waitHelpers');

const LOAD_PAGE_TIMEOUT = 10000;


/**
* show displayed selector on the page matching with the id/class_name in the parameter.
* useful in situations where a mobile and desktop versions are loaded at the same time, so there are multiple
Expand All @@ -15,19 +14,21 @@ const LOAD_PAGE_TIMEOUT = 10000;
* this.getDisplayedElements('section#loginarea input[data-testid="username"]')
*/

async function getDisplayedElement(selector){
async function getDisplayedElement(selector) {
let displayedElements = []; // initialize an array where displayed element(s) will be stored
const presentElements = await driver.$$(selector); // puts mathing elements in the array
for (let element of presentElements) {
let isDisplayed = await element.isDisplayed()
let isDisplayed = await element.isDisplayed();
if (isDisplayed) {
displayedElements.push(element)
displayedElements.push(element);
}
}
if (displayedElements.length!==1) {
throw new SelectorConflictException('multiple/or none displayed selectors with the same identifier on the page!')
if (displayedElements.length !== 1) {
throw new SelectorConflictException(
'multiple/or none displayed selectors with the same identifier on the page!'
);
} else {
return displayedElements[0]
return displayedElements[0];
}
}

Expand Down Expand Up @@ -215,6 +216,7 @@ async function getValueOfElement(selector) {
async function getTextFromAllElements(selector) {
await waitHelpers.waitUntilPageLoads();
const listOfElements = await getListOfAllElements(selector);
console.log('pampelmuse', listOfElements);
let textList = await getTextListFromListOfElements(listOfElements);
return textList;
}
Expand Down Expand Up @@ -262,26 +264,27 @@ async function getElementIncludingText(selector, text) {
return listOfElements[index];
}

function SelectorConflictException (message) {
function SelectorConflictException(message) {
this.message = message;
this.name = "SelectorConflictException";
this.name = 'SelectorConflictException';
}

async function moveToElement(selector){
async function moveToElement(selector) {
await waitHelpers.waitUntilNuxtClientLoads();
let moveToElement = await driver.$(selector);
let xOffset = await moveToElement.getLocation('x');
let yOffset = await moveToElement.getLocation('y');
if (!(await moveToElement.isDisplayedInViewport())){
if (!(await moveToElement.isDisplayedInViewport())) {
moveToElement.scrollIntoView({
behavior: "smooth",
block: "end",
inline: "nearest"});
behavior: 'smooth',
block: 'end',
inline: 'nearest',
});
await driver.pause(500);
await waitHelpers.waitUntilElementIsPresent(moveToElement);
moveToElement.moveTo(xOffset, yOffset);
await waitHelpers.waitUntilElementIsVisible(moveToElement);
}else{
} else {
moveToElement.moveTo(xOffset, yOffset);
await waitHelpers.waitUntilElementIsVisible(moveToElement);
}
Expand Down Expand Up @@ -316,6 +319,6 @@ module.exports = {
getElementByText,
getElementIncludingText,
getDisplayedElement,
loadPageNuxtClient,
loadPageNuxtClient,
moveToElement,
};

0 comments on commit fcd4f71

Please sign in to comment.