Hi Ashish,
I am working on an application related to Sales Force Lightning and no matter what I do, scroll is very important for automating a lot of features. I try : Java Script Executor- scroll into view, Windows.scrollBy, Actions class (focus element)- but none of this works! Can you suggest any other way ?
Regards,
Dipika Gupta
Instructor
Ashish Thakur Replied on 09/10/2019
You can make use of the below code.
String elementLocation = (driver.findElement(By.xpath("/html/body/div[7]/a[2]")).getLocation().toString());
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo" + elementLocation);
Hi,
I tried this it does not work. I tried Coordinates class as well but it fails. Looks like the lightning web components hide the web elements to prevent user interaction.
Instructor
Ashish Thakur Replied on 15/10/2019
Try using Actions Class or Robots Class. You can automate Page Down Key using one of these classes.
Hi, I tried even that : Robot class and action (Draggable). A temporary solution of reducing the laptop resolution solved the problem, but this is not correct ideally. If I try to use Dimension class of Selenium then it reduces the size of the window , yet scrolling cannot be avoided. Do you know any code resolution to reduce the size of the webpage to that extent that it is not dependent on scrolls and I can click on any element or enter any text without any ambiguity? SalesForce Lightning does not allow us to perform scrolls and sometimes when we are lucky it does , but I am looking for a work around because we can change salesforce
Instructor
Ashish Thakur Replied on 15/10/2019
Before suggesting a solution, we need to analyze the application and the project.
Please share your project here and share your SalesForce Lightning credentials at info@qtpselenium.com mentioning this post's link in the message.
Hi,
Unfortunately I cannot share the code. It is confidential. I asked my colleagues too.
Instructor
Ashish Thakur Replied on 16/10/2019
Without analyzing the code and the application, we won't be able to suggest anything.