I'm wondering if there is any way to test for where focus is set on a page, using Laravel Dusk. I have a form whose first element should always receive focus when the page loads. I don't see anything obvious in the Dusk documentation for this. I'm using Laravel 5.5.
Use this:
$element = $browser->element($selector);
$this->assertTrue($browser->driver->switchTo()->activeElement()->equals($element));
UPDATE: In Dusk 3.0.8 you can use assertFocused() and assertNotFocused().
Related
I am working on an issue which is in existing project.The project is build in laravel (version 5.8).The issue is that when any web pages is loaded of web application then first line of code will be commented.And there is one more issue is that when any form is submitted through ajax then in response always i got "<? (PHP tag)" as prefix.So i am not identifying how it is coming.
I have tried one solution that removing the PHP tag from the empty routes file but still issue is not been fixed.Below is the link of it from where i got the way of solving the issue but it is not working :
https://github.com/laravel/framework/issues/21581
Below is the image of the commented code and the response of ajax which i am getting all the time.
1) First line of code will be commented all the time when any of the page is loaded.
2) When any of the ajax call of the application then in response i got "<? (PHP tag)" as prefix.
Please provide me solution as soon as possible because i am trying to resolve the issue since a week but still issue is not fixed.Thanks in advance.
I have been trying since weeks now to debug my laravel/vuejs app with absolutely no success, so I am trying to understand what happens . I am debugging the "old way", displaying errors manually... And I get a bit crazy :)
PHP debugbar seems fabulous but for some reason it only shows up when I have a 404 error... I Would like to see it all the time.
Also, "dd()" juste doesnt do anything when I do for example:
public function emailexists(string $email){
dd($email);
//this doesn't work either
var_dump($email);
die();
}
I guess there is something I forgot. I am a beginner with PHP.
EDIT: could it be because I am using VueJS ?
EDIT2: after Thomas' answer :
I guess the lifecycle is ended correctly (unless I need to do something specific? I am just calling my PHP controller through axios from my vueJS view)
But here is my view.blade, could it be the issue?
#extends('template')
#section('content')
<div id="app">
<vuecomponent ></vuecomponent >
</div>
#endsection
The debugbar gets added at the end of the request lifecycle (after middleware). Failing to properly end the lifecycle the intended way will yield the result of not having a debugbar. Both dd and die are PHP functions that stop execution immediately.
As for VueJS:
Vue itself will not show the debugbar, just because Laravel is installed next to the Vue entrypoint.
That doesn't have to be a problem if you use a (Blade) view to setup Vue. However if you bypass Laravel entirely on DOM output, that yes the debugbar won't be part of it.
When you use PHP, Laravel or Vuejs all dd() or var_dump() would be useful if you can track your requests. May you just need to use a browser inspector which could show you requests responses.
I am creating a cms app where a user can post their own, of course!
The problem I am facing is when using Carbon. I am using Carbon to make the created_at readable to humans using diffForHumans(). However, the time updates only when I refresh the page.
How can I dynamically refresh the time (Carbon) without having to refresh the page?
Carbon is a PHP package, and PHP renders your templates into HTML/CSS only once as a response when the user requests for a particular page.
What you're looking for instead is to implement this counter in Javascript. Javascript actually runs on the client's browser, whereas PHP is only run on the server itself.
I have a CI view which uses jquery tab to show some content. One of the tabs loads another controller which uses grocery crud. So the initial display is embeded inside this view. However if I try to edit or update it opens it in a completely seperate page and from then all actions on the grocery crud is in a separate page. How can I embed grocery crud inside a CI view?
This is not yet supported in grocery CRUD but it will be supported as for the new big release of version 1.4 that it is not yet released. If you like to implement the alpha version at your project, you can simply download the latest zip file from github https://github.com/scoumbourdis/grocery-crud (https://github.com/scoumbourdis/grocery-crud/archive/master.zip) and simply go to: application/config/grocery_crud.php and change the line:
$config['grocery_crud_dialog_forms'] = false;
to:
$config['grocery_crud_dialog_forms'] = true;
That's it actually :) . You can see some scrennshort to make sure that this is what you need.
I suggest though for you to wait, at least for the BETA version to release, as it is not 100% done yet.
you should allow sending csrf with the ajax call to allow loading the file with ajax
when we use
$config['csrf_protection'] = TRUE;
what is the place that can i edit to send CSRF of codeigniter with the ajax call ?
I am working on small php application using codeigniter
I did just copy paste .youtube embed code on form field. it doesn’t work just show the code as it is. How so i do it ?
You probably have xss_clean active in your $_POST which modifies $_POST variables.