Before using click and xclick I have an executeScript_Sandbox (javascript) that checks if the element is visible and if not, smoothy scrolls to ‘nearest’. Then I want the click or xclick to click just there and not to scroll the element to center. Somewhere I read that I should set !waitForVisible to false, which I tried, but that didn’t work.
Hi, can you please post a test macro to clarify the question?
{
"Command": "storeXpathCount",
"Target": "xpath=//div[@class='pagination']//li[@class='next']/a[@class='icon-arrow-right-after'][span[text()='Next']]",
"Value": "nextExists",
"Description": "Check if next button exists"
},
{
"Command": "gotoIf",
"Target": "${nextExists} == 0",
"Value": "END",
"Description": ""
},
{
"Command": "executeScript",
"Target": "
const nextButton = document.evaluate(
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
if (nextButton) {
if (
!nextButton.getBoundingClientRect().top ||
nextButton.getBoundingClientRect().bottom > 0
) {
nextButton.scrollIntoView({
behavior: 'smooth',
block: 'nearest'
});
return 1;
}
return 2;
}
return 0;
"
"Value": "nextButtonVisible",
"Description": "This command scrolls the "Next" button into view"
},
{
"Command": "pause",
"Target": "2000",
"Value": "",
"Description": "Visually verify that it work and that I can see the next button"
},
{
"Command": "click",
"Target": "xpath=//div[@class='pagination']//li[@class='next']/a[@class='icon-arrow-right-after'][span[text()='Next']]",
"Value": "",
"Description": "Click next button"
},
The click will always scroll the button to the vertical middle of the viewport, although it is already visible in the viewport. I don’t want that extra scoll. The button should be clicked where it is without extra scrolling.