Comments (15)
fyi; as a work around I have been use the script method to set the date. It's annoying but it works.
$this->browse(function ($browser) use ($user) {
$browser->loginAs($user)
->visit('/sompage')
->script([
"document.querySelector('#the_date_field').value = '2017-02-23'",
]);
$browser->{do other stuff}
});
One thing to keep in mind is that script
does not return the $browser
instance so it needs to be terminated and the browser variable recalled.
from dusk.
Another solution is use the keys() method
keys('.selector', 'datetotype');
from dusk.
It looks like this issue has been around for at least 3 years:
http://stackoverflow.com/questions/15360362/clear-date-input-fails-on-chromewebdriver
I've created a PR (#125) to allow typing into a field without clearing it, but I'm not sure if that's the way to go.
from dusk.
Just found out there's already a method for this: append
.
from dusk.
Tested this just now and it works for me, but my setup works through selenium and firefox. I could never get chromedriver to work on centos 6
from dusk.
Hmm, maybe just a ChromeDriver issue then? If someone can confirm then happy to report this elsewhere?
from dusk.
@devdorego I tried use the keys method but every time it would misconfigure the date. Maybe you found a reliable way?
->keys('#date', '2017-03-01')
from dusk.
@devinfd If you look at my original report I gave an example of how keys() can be used as a workaround.
from dusk.
Follow up, I just end up creating a macro for this:
use Laravel\Dusk\Browser;
Browser::macro('typeDate', function ($selector, $year, $month, $day) {
$this->keys($selector, $day)
->keys($selector, $month)
->keys($selector, $year);
return $this;
});
$this->browse(function ($browser) use ($user) {
$browser->loginAs($user)
->visit("/somepage")
->typeDate('#some_date', '2017', '04', '11');
});
The problem with this is that its depended on the users system date format. Ie: the date may not be displayed in day/month/year format.
from dusk.
@devinfd
Replace
->keys('#date', '2017-03-01')
with
->keys('#date', '20170301') // omit the dashes
from dusk.
from dusk.
Closing this issue because it's already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue.
from dusk.
Hmm I can actually reproduce this. Unfortunately since this is related to the ChromiumDriver it's not really a Dusk issue. I can however re-send a the PR that was closed but with a different method. I'll try to do that soonish but feel free to send one in before me.
from dusk.
I ultimately resolved this by not using an input[type="date"] field. Partly because of this issue but also my users were complain about the browser venders date UI.
from dusk.
This worked perfectly fine for me with Chromium driver:
use Carbon\CarbonInterface;
use Facebook\WebDriver\WebDriverKeys;
use Illuminate\Support\Carbon;
use Laravel\Dusk\Browser;
Browser::macro('inputDate', function ($selector, $date) {
$date = $date instanceof CarbonInterface ? $date : Carbon::parse($date);
$this->resolver->findOrFail($selector)
->sendKeys([
$date->format('d'),
$date->format('M'),
WebDriverKeys::TAB,
$date->format('Y'),
]);
return $this;
});
$browser
->inputDate('@date', $tomorrow = now()->addDay())
->assertInputValue('@date', $tomorrow->format('Y-m-d'))
from dusk.
Related Issues (20)
- [7.9.1] unknown error: cannot find Chrome binary HOT 5
- `--stop-on-failure` option no longer seems to work HOT 1
- Driver won't download with Telescope enabled HOT 8
- unknown error: cannot find Chrome binary HOT 1
- Error This version of ChromeDriver only supports Chrome version 114 Current browser version is 118.0.5975.0 HOT 1
- Assertion failure can lead to timeout if using multiple browsers HOT 5
- Test class with no tests gives non-zero stderr status, but no warning to stdout and shows all tests pass HOT 5
- Unexpected behaviour when working with multiple checkboxes HOT 1
- waitForTextIn() broken in dusk 7.11.2 HOT 2
- Unknown option "--ansi" and "--no-ansi"
- Laravel Dusk doesn't trigger on @input when attached to <select> only on @change when using Vue HOT 2
- When running `php artisan dusk` the tests do not complete. They just hang. - MacOS Sonoma 14.2.1, Chip: M3 Pro HOT 9
- Throwing an exception in a dusk test inside the browser callback results in timeouts HOT 2
- vueAttribute does not work with Vue 3 and vite build. only with vite dev. HOT 6
- Failed to load assets in Sail HOT 4
- Dusk slows down after call to dump() HOT 1
- Unknown options --verbose / -v / --quiet / -q HOT 3
- The driver fails to read the environment properly HOT 3
- Chromedriver 127 renames wrong file on install HOT 2
- Dusk @-selectors cannot be combined with other CSS selectors for the same element HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dusk.