I'm having problems with the Laravel Dusk type() and value() method. I'm getting the following error.
$ php artisan dusk --group=activation
Warning: TTY mode is not supported on Windows platform.
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
DevTools listening on ws://127.0.0.1:12599/devtools/browser/84028821-2ca1-4d26-b66c-4697d2302117
E 1 / 1 (100%)
Time: 13,35 seconds, Memory: 18,00MB
There was 1 error:
1) Tests\Browser\CounselorActivationTest::testActivationWithSubscriptionWithPasswordLogin
Facebook\WebDriver\Exception\UnknownServerException: unknown error: call function result missing 'value'
(Session info: chrome=68.0.3440.84)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.17134 x86_64)
D:\devYubu\yubu\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:114
D:\devYubu\yubu\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:326
D:\devYubu\yubu\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:547
D:\devYubu\yubu\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:308
D:\devYubu\yubu\vendor\laravel\dusk\src\Concerns\InteractsWithElements.php:97
D:\devYubu\yubu\tests\Browser\tests\userActivation\CounselorActivationTest.php:58
D:\devYubu\yubu\vendor\laravel\dusk\src\TestCase.php:91
D:\devYubu\yubu\tests\Browser\tests\userActivation\CounselorActivationTest.php:95
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
I'm using the value method 2 times, I can see that the first one actually fills in the form, however the second one fails..
->value('input[name=external_id]', $counselor->getAttribute(User::COLUMN_EXTERNAL_ID))
->value('input[name=name_full]', $counselor->getAttribute(User::COLUMN_NAME_FULL))
When I'm using type(), the first one also fails:
->type('external_id', $counselor->getAttribute(User::COLUMN_EXTERNAL_ID))
->type('name_full', $counselor->getAttribute(User::COLUMN_NAME_FULL))
In using Windows 10. I'm running Dusk on Windows (I have PHP 7.2 installed). My application runs on Homestead with PHP 7.0. I'm using Laravel 5.4
This was a problem with an outdated ChromeDriver.
Big thanks to Jonas Staudenmeir, who has created a package for updating your Chromedriver:
https://github.com/staudenmeir/dusk-updater
I echo #Martijn Ihhoff. Get the staudenmeir updater -
https://github.com/staudenmeir/dusk-updater
After you download and run it (follow instructions on linked page above) be sure to kill the old ChromeDriver though. Here's how I did it:
run ps -aux then find the process ending with /vendor/laravel/dusk/bin/chromedriver-linux the second parameter from the left on that line will be the PID (Process ID) copy it (and any other PID's of running chromeDrivers) and then kill each of them by running kill ##### where ##### is the copied PID. Once all processes are killed, re-run dusk.
Related
As the title says, I have a VPS running on CentOS 7, I installed all the requisites for Laravel, PHP 7.3, but it still giving me 'Server Error 500'.
Note that this is a fresh installation of Laravel with composer.
My CentOS version is CentOS Linux release 7.2.1511 (Core)
PHP version is PHP 7.3.6 (cli)
I manually installed all the necessary modules from PHP
What I have already tried
I already did quite a lot of research:
Laravel giving 500 internal error on centos 7 with apache and php 7
I followed what the answer to that questions says and still the same for me.
I did also set up permissions correctly following this other post:
How to set up File Permissions for Laravel 5 (and others)
Also these ones
Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
https://www.ionos.com/community/server-cloud-infrastructure/apache/how-to-fix-http-error-code-500-internal-server-error/
And a bunch of more articles I read on another websites.
These are the permissions for the project folder:
drwxr-xr-x 13 apache apache 4096 May 31 05:23 laravel
And for storage:
drwxr-xr-x 5 apache apache 4096 May 31 04:44 storage
Tried generating the key and got this:
[root#server laravel]# php artisan key:generate
ErrorException : file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory
at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
> 96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1 file_get_contents("/var/www/laravel/.env")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
2 Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:soTdeaCmsY1ELnpJLCcYkBJjY6SWiLYwY+Mvoxl9wOw=")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:80
Please use the argument -v to see more details.
[root#server laravel]#
Seems like you miss the Laravel environment configuration file.
In a fresh Laravel installation you should have a .env.example file. Duplicate that one and rename it to .env then run the php artisan key:generate command.
Did you created the var/www/laravel/.env file from your var/www/laravel/.env.example file?
So, I fixed it configuring properly the .env and generating a key as #mdexp mentioned.
So for everyone having problems, check the links in my question and set everything correctly
I am using nagios check_logwarn to capture changes to log files.
In order to test my setup, I have been manually adding the following log line to the concerned log file -
[Mon Mar 20 14:24:31 2017] [hphp] [12082:7f238d3ff700:32:000001] []
\nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.0.6311-beta
app/webroot/openx/www/delivery/postGetAd.php on line 483
The above should get caught by the following nagios command, because it contains the keyword "Fatal"
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_`(date +'%Y%m%d')`.log "^.*Fatal*"
Output (as expected) -
Log errors: \nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.
0.6311-beta
\nFatal error: entire web request took longer than 10 seconds and timed out in /var/cake_1.2.0.6311-beta
Running this command directly works (case 1), but it seems invoking the same via a PHP exec which is triggered via a Jenkins project is not catching the same (case 2).
Following is the PHP code of case 2 -
$errorLogCommand = '/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_'.$date.'.log "^.*Fatal*"';
$output = exec($errorLogCommand);
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." Checked error key words in error_".$date.".log. command -> ".$errorLogCommand, FILE_APPEND);
if($output!="OK: No log errors found")
{
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." - Hiphop errors -> ".$output, FILE_APPEND);
$failure=true;
break;
}
else
{
file_put_contents('/var/cake_1.2.0.6311-beta/deployment/deployment.log', "\n ".date("Y-m-d H:i:s")." - No Error found -> ".$output, FILE_APPEND);
}
Following is the output -
2017-03-20 14:16:45 Checked error key words in error_20170320.log. command -> /usr/local/nagios/libexec/
check_logwarn -d /tmp/logwarn_hiphop_error -p /mnt/log/hiphop/error_20170320.log "Fatal"
2017-03-20 14:16:45 - No Error found -> OK: No log errors found
Note that with the same nagios command (/usr/local/nagios/libexec/check_logwarn) as in case 1, log error is not detected in this case, unexpectedly.
Following are my observations of the contents of the internal tracker file which nagios generates - /tmp/logwarn_hiphop_error/mnt_log_hiphop_error_20170320.log -
When error is detected in case 1, following are the changes in the file -
Before running command
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="110"
POSITION="111627"
MATCHING="true"
After running command
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="116"
POSITION="112087"
MATCHING="false"
Also, following are the changes to the same file in case 2 -
Before running php file
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="102"
POSITION="109329"
MATCHING="true"
After
# logwarn 1.0.10 state for "/mnt/log/hiphop/error_20170320.log"
INODENUM="1208110246"
LINENUM="110"
POSITION="111627"
MATCHING="true"
I am not sure why the MATCHING parameter is true in the case 2, whereas in case 1 it is false. In fact, the error matching happened in case 1.
Update
I tried wrapping the command in an escapeshellcmd, to ensure that the regex is not being stripped out -
$output = exec(escapeshellcmd($errorLogCommand));
but still no change in output.
Update 2
Found that I had line breaks in the log line I was manually adding. Removing those fixed it consistently for the case of running the PHP file from command line. However, the problem is still reproducible consistently for the case 2, where I am triggering the project via Jenkins and this file gets called in one of the hooks of AWS code deploy.
Well, it seems this is not going to get solved so easily. The problem got fixed for manual invocation of the PHP file, but on invocation via Jenkins, I am still getting the same problem consistently.
The logwarn documentation mentions support for a negative checking expression.
Please try pre-pending an exclamation mark (!) before the pattern string to exclude rather than include these matches
I am trying to setup functional tests on my Centos Server using Selenium Web Server and Phpunit.
When I run the tests, I get an error in the command line :
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:
Unable to connect to host vmdev-pando-56 on port 7055 after 45000 ms.
Firefox console output: Error: no display specified
I've been doing research for more than three days and I couldn't find a solution. I read many posts, including SOverflow. As per my understanding, everything is properly set up, and yet I am experiencing the same problem as many other people, and the solutions that work for them seem to be not working for me.
This is my setup:
OS: Centos 6.5 x86 in command line (no GUI)
PHP: 5.6
Phpunit: 3.7, although I also tried with 5.3
Selenium standalone web server: 2.53, downloaded from here, although I also tried with 2.9
Xvfb system: xorg-x11-server-Xvfb
Firefox: 38.0.1, although I also tried with 38.7
I also set the DISPLAY to :99 in my bash profile:
This is what I do to set up the environment:
First, I launch the Xvfb system: /usr/bin/Xvfb :99 -ac -screen 0 1280x1024x24 &
Then I launch the Selenium server: /usr/bin/java -jar /usr/lib/selenium/selenium-server-standalone-2.53.0.jar &
I launch Firefox: firefox & (although I know this is not necessary, but just in case)
All of the three processes are running in background.
At this point, I know that Firefox is operative, as well as the X buffer. I can run the command firefox http://www.stackoverflow.com & and then take an snapshot of the buffer by executing import -window root /tmp/buffer_snapshot.png, which happens to be something like this:
I of course received a warning on the terminal: Xlib: extension "RANDR" missing on display ":99", but I read countless of times that this is not a problem.
Anyway, the problem begins just now.
I've written a rather simple functional test (please notice that other tests I've written other than functional, they work just fine, so the environment in that respect seem to be properly configured):
<?php
namespace My\APP\BUNDLE\Tests\Functional\MyTest;
use PHPUnit_Extensions_Selenium2TestCase;
class HelloWorldTest extends PHPUnit_Extensions_Selenium2TestCase {
protected function setUp() {
$this->setBrowser('firefox');
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowserUrl('http://www.stackoverflow.com');
}
public function testTitle() {
$this->url('/');
$this->assertEquals("1", "1");
}
}
And when I run the test by issuing phpunit HelloWorldTest.php, I get the following error:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:
Unable to connect to host vmdev-pando-56 on port 7055
after 45000 ms. Firefox console output:
Error: no display specified
Checking the log file generated by selenium, I found the following (interesting) lines:
21:55:46.135 INFO - Creating a new session for Capabilities [{browserName=firefox}]
[...]
java.util.concurrent.ExecutionException:
org.openqa.selenium.WebDriverException:
java.lang.reflect.InvocationTargetException
Build info: version: '2.53.0',
revision: '35ae25b',
time: '2016-03-15 17:00:58'
System info: host: 'vmdev-pando-56',
ip: '127.0.0.1',
os.name: 'Linux',
os.arch: 'i386',
os.version: '2.6.32-431.el6.i686',
java.version: '1.7.0_99'
Driver info: driver.version: unknown
[...]
(The file contains the complete stack trace dump, and the original message of no display specified)
No errors in the Xvfb log file.
At this point I have no clue of what I am doing wrong.
Can anyone help?
Thanks a lot
A reason for the Unable to connect error is that the version of Selenium Server does not know how to work with the version of Firefox you have installed. Selenium standalone web server 2.53 is the latest and greatest. selenium-firefox-driver is also 2.53. Firefox version 38 is old. I am running firefox 45.0.1 with selenium 2.53.
I was happily working away in my development environment and suddenly I started getting the following error:
PHP Fatal error: Cannot redeclare composerRequire7a368ac394ae1d2e857becf2a235ebaa() (previously declared in [APP_ROOT]/vendor/composer/autoload_real.php:56) in [APP_ROOT]/vendor/composer/autoload_real.php on line 59
I haven't made any changes to speak of in composer dependencies (although I think I did do a composer update somewhere in that timeframe but no changes to the dependencies/packages used so nothing big should have changed.
Notably, when I checkout the repo on my laptop I do NOT get this error but if I git clone a clean repo and then composer install on my main development machine I DO get this error. So I'm assuming it must have some machine-specific origin but I'm running out of ideas on what that might be.
Any help would be greatly appreciated.
Note: I'm running PHP 5.3.28 on OSX; my app uses namespacing and is PSR0 compliant
Also of note is that I'm running PHPUnit 4.0.17 and the error is triggered at the very first stages of trying to run a unit test (it doesn't matter WHICH unit test). Here's the stack trace:
0.0009 636648 1. {main}() [APP_BASE]/vendor/phpunit/phpunit/phpunit:0
0.0465 1423664 2. PHPUnit_TextUI_Command::main() [APP_BASE]/vendor/phpunit/phpunit/phpunit:54
0.0465 1424280 3. PHPUnit_TextUI_Command->run() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:132
0.0465 1424280 4. PHPUnit_TextUI_Command->handleArguments() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:141
0.0674 2123344 5. PHPUnit_TextUI_Command->handleBootstrap() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:638
0.0681 2139872 6. PHPUnit_Util_Fileloader::checkAndLoad() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:808
0.0681 2140008 7. PHPUnit_Util_Fileloader::load() [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:77
0.0774 2144176 8. include_once('[APP_BASE]/tests/test-loader.php') [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:93
0.0775 2146736 9. include('[APP_BASE]/vendor/autoload.php') [APP_BASE]/tests/test-loader.php:2
Delete composer.lock and vendor/ and run composer update again.
I had this problem when I made a copy of an existing project directory and tried to run phpunit on the new directory. Finally figured out that when I executed phpunit, it was running out of the old directory. I ran this:
which phpunit
And saw that it was running from my composer vendor directory:
/home/vagrant/Code/MYOLDPROJECT/api/vendor/bin/phpunit
I ran phpunit from the new directory and the problem disappeared:
/home/vagrant/Code/mynewproject/api/vendor/bin/phpunit
I have got a test case in my test class and some problems with it. I run the script from console. The script is executed to a certain point and then the test fails with error:
Could not connect to the Selenium RC server.
Here is log from console:
PHPUnit 3.5.15 by Sebastian Bergmann.
E
Time: 01:56, Memory: 4.00Mb
There was 1 error:
1) someTest::testSomething
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
/var/www/path.../someTest.php:105
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Line 105 in my test script:
$this->clickAndWait("//a[text()='Next']");
And here is Selenium log:
14:00:40.983 INFO - Command request: click[//a[text()='Next'], ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.205 INFO - Got result: OK on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.207 INFO - Command request: waitForPageToLoad[600000000, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Command request: testComplete[, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Killing Firefox...
14:02:11.506 INFO - Got result: ERROR: Got a null result on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.508 INFO - Got result: OK on session
I tried with Selenium Server Standalone 2.19.0, then with 2.20.0 - the same result.
The server is still running, even after test interruption.
My question is:
why this error occurs suddenly and unexpectedly interrupts the script?
PHPUnit 3.5.15
Selenium Server Standalone 2.19.0 & 2.20.0
Firefox 3.6.18
Ubuntu 10.04
Try with $this->click("link=Next");
The reason behind this, When selenium try to find a text and the page is not fully loaded or there are ambiguous text then selenium throws it and shows like "Could not connect to the Selenium RC server". verification/assertion of text is making problem some times.