How to make scrollIntoView method work in Laravel dusk - laravel-dusk

Description:
The scrollIntoview dusk method is not working as expected.
Can anyone please point me the right version of laravel/dusk, chrome driver version to be used to make it work again.
Currently I am using theses versions while running the script.
Laravel framework version: 6.2
laravel/dusk: 6.11
php:7.2
Chrome driver: 88.0.4324.96.
Thank you in advance.

There is a wide range of unexpected behaviours in scrollIntoView(), and related reasons...
Among the many: my own experience was about the Bootstrap navbar placed above the scrolled element, resulting in many "Other element would receive the click" errors. I fixed it with my own Browser Macro, scrolling the element at the bottom of the page (instead of top):
\Laravel\Dusk\Browser::macro('scrollView', function ($selector) {
$selector = addslashes($this->resolver->format($selector));
$this->driver->executeScript("document.querySelector(\"$selector\").scrollIntoView({block: 'end'});");
$this->pause(500);
return $this;
});

Related

TestCafe takeElementScreenshot behaviour changed - how do I get the old behaviour

I upgraded from Testcafe 1.6.0 to 2.0.1.
I noticed there are differences in how TestCafe takes screenshots.
This is a screenshot from 1.6.0:
This is a screenshot taken with 2.0.1:
This is how it actually looks:
As you can see in 1.6.0 and in the original the "Q" looks more like an "O" because it is cropped - like other letters. overflow: hidden is set on the element.
It makes sense. This is the actual box of the screenshottet element:
The actual text is in a div element inside the screenshottet element:
It seems like in 2.0.1 it disables overflow: hidden on the screenshottet element to take the screenshot.
Is there a way to re-enable the old behaviour?
TestCafe published a new version - 2.1.0-rc.1 with a fix for the issue with screenshosts. Please update testcafe and check the issue again. If it doesn't help, create a simple sample with the following template: https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=TYPE%3A+bug&template=bug_report.yaml

scroll until the element is in view using Selenium2Library Keyword

I am using Robot Framework for my web application automation execution.I had found one such solution using Selenium Web-driver.
scroll until the element is in view using Selenium Webdriver
But I wanted to accomplish this using Robotframewrok-Selenium2Library.
Please suggest such keyword if any.
Thanks.
Finally I got the solution to my query. I have to download the ExtendedSelenium2Library from : Github_Page
then I installed it and it is working fine now.
Thanks.
ExtendedSelenium2Library solved the problem of scrolling down and selecting an element. I used the keyword 'Scroll Element Into View' for my application. However the ExtendedSelenium2Library will not work with the higher versions of the selenium2library.
Below is my 'pip freeze' command output which is working
robotframework==3.0.2
robotframework-extendedselenium2library==0.9.1
robotframework-selenium2library==1.8.0
robotframework-seleniumlibrary==2.9.2
selenium==3.8.0
urllib3==1.22
I was stuck at similar blockade and i could resolve as below:
Hope this might be of little help!
Use ExtendedSelenium2Library Library...
Example:
***Settings***
Library ExtendedSelenium2Library
*** Keywords ****
Add Your Methods
#Execute Javascript window.scrollTo(0,200);
Scroll Element Into View ${YourElement}
Wait Until Element is visible ${YourElement} timeout=5s
Set Focus To Element ${YourElement}
Click Element ${YourElement}

Unable to get Gamepad events on Chromium Version 44.0.2383.0

I'm trying to get my gamepad events in chromium. Everything works perfectly fine on Chrome Version 44.0.2403.130 m with this code :
var gamepadList = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
But on the WebVR chromium version made by Brandon Jones, I can't get any feedback, the 'navigator.getGamepads()' function returns only an array of four undefined variables.
Is it not supported yet? Or do I need to do something specific?
Thanks for the help!
Seems to work for me using this test page:
http://www.html5rocks.com/en/tutorials/doodles/gamepad/gamepad-tester/tester.html
Keep in mind that, due to fingerprinting privacy concerns, you to press a "face" button on the controller before it is visible to the API.

Element not being added when running test through webdriver

I am working on writing a story for a bdd framework which uses jbehave/selenium/webdriver and am having a problem where the test encounters an error while running the story but appears to be fine when running manually. I'm having a problem where javascript for the functionality I'm testing behaves slightly different when I'm running tests manually on firefox vs through selenium web driver on the same system/version of firefox and this difference is causing a js error.
I've debugged and basically the root of the problem appears to be that var request_XML_container = $('div_appendpoint_id'); returns something different when I'm running the test manually vs when I run through the bdd framework.
var request_XML_container = $('div_appendpoint_id');
request_XML_container.innerHTML = encoded_xml_from_request;
var pos = method_to_get_position('id_of_place_div_should_be_appended_to');
// JS exception is thrown saying that style is not defined **ONLY**
// when running through web driver. Running test manually on
// same system and same browser works fine.
request_XML_container.style.left = (pos[0] - 300) + 'px';
request_XML_container.style.top = (pos[1] + 25) + 'px';
request_XML_container.style.display = "block";
Why this would work fine when running manually that var request_XML_container = $('div_appendpoint_id'); would return an item with style defined, but when running through webdriver that the style attribute of the element would not be defined?
UPDATE: I had originally thought that this was updating an iframe, but I read the markup wrong and the iframe I saw is a sibling - not a parent - of the element where the response is being appended to. I'm trying to simply append the response to a div. To be honest, this only makes things more confusing as grabbing a div by id should be pretty straight forward and I'm now sure why webdriver would be producing a different return element in this situation.
UPDATE 2: Steps to reproduce and information about the system I'm on:
Use webdriver to navigate to this url: http://fiddle.jshell.net/C3VB5/11/show/
Have webdriver click the button. It should not work
Run your test again, but pause put a breakpoint at your code to click the driver
Click the button on the browser that webdriver opened. It should not work
Refresh the browser page on the browser that webdriver opened. Now, it should work.
System details:
OS : OS X 10.8.5 (12F37)
IDE : Eclipse Kepler: Build id: 20130614-0229
Browser (used manually and by webdriver) : Firefox 23.0.1
Selenium version: 2.35.0
UPDATE 3: I have provided this maven project on github to aid in reproducing: https://github.com/dkwestbr/WebdriverBug/tree/master/Webdriver
Synopsis/tl:dr; Basically, in certain situations it appears as though webdriver is overwriting the '$()' javascript method with a method that does not return an HTMLElement with innerHTML or style defined (among other things). This post details the issue and how to reproduce.
I have opened this ticket to track the issue: https://code.google.com/p/selenium/issues/detail?id=6287&thanks=6287&ts=1379519170
I have confirmed that this is a bug with the Thucydides framework (understandable since they still aren't at a 1.0 release).
Issue can be tracked here: https://java.net/jira/browse/THUCYDIDES-203

Selenium: Can't SendKeys() to an item that was below the visible window but was made visible by Click()

I have this problem with a text field that is visible at the time of the SendKeys. I'm using IEDriverServer.exe and C#.
Here's how I can reproduce the problem:
The text field in question is visible in the window but you have to scroll down to see it. To scroll down I click on the element using code like this:
var element = driver.FindElement(By.Xpath("…"));
element.Click();
This scrolls the window down and makes the text field visible.
But when I try to send text to now-visible window:
element.SendKeys("blah");
I get the exception:
When_applicant_enters_application.Should_be_instantly_approved_on_external threw exception: OpenQA.Selenium.ElementNotVisibleException: Element is not displayed
How can I fix or workaround this problem?
Selenium version: 2.32.1
OS: Windows 7
Browser: IE
Browser version: 9.0.15
I've written code demonstrating the problem and submitted it to the Selenium tech support volunteers.
The full discussion is at http://code.google.com/p/selenium/issues/detail?id=5620
but the take-home is:
// Doesn't work
// driver = new InternetExplorerDriver();
// driver.Navigate().GoToUrl(#"D:\CGY\selenium\Bug5620\Bug5620\Bug5620.htm");
// Works
// driver = new FirefoxDriver();
// driver.Navigate().GoToUrl(#"D:\CGY\selenium\Bug5620\Bug5620\Bug5620.htm");
// Works
driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl(#"http://localhost:8080/Bug5620/"); // Hosted on Tomcat
so there may be a problem that possibly involves IE, IE security settings, Visual Studio local servers and/or the IE Driver. This may not even be a code problem, but something that needs to be documented, since other people are apparently running into the problem.
I don't know where the problem is exactly but I do have a work-around at this point, which is to use the Firefox Driver.
Thanks for your help, Jim. If you find out a better way of dealing with the problem, please add an answer here for the other folks.