Chapters
23 Chapters
|
1:59:49
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
18.
Master JavaScript with Waits & Debugging
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses a very old version of Symfony. The fundamentals of Behat are still valid, but integration with Symfony will be different.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.4.0, <7.3.0",
"symfony/symfony": "^2.7", // v2.7.4
"twig/twig": "^1.22", // v1.22.1
"sensio/framework-extra-bundle": "^3.0", // v3.0.16
"doctrine/doctrine-bundle": "^1.5", // v1.5.1
"doctrine/orm": "^2.5", // v2.5.1
"doctrine/doctrine-fixtures-bundle": "^2.2", // v2.2.1
"behat/symfony2-extension": "^2.0" // v2.0.0
},
"require-dev": {
"behat/mink-extension": "^2.0", // v2.0.1
"behat/mink-goutte-driver": "^1.1", // v1.1.0
"behat/mink-selenium2-driver": "^1.2", // v1.2.0
"phpunit/phpunit": "^4.8" // 4.8.18
}
}
8 Comments
Dear SymfonyCasts,
I've run into a problem where Selenium2 is interacting with the production database instead of the test database. As a result, when adding a new product, it's being inserted into the
bdd.producttable rather thanbdd_test.product. How can I configure Selenium2 to utilize the test database instead?I'm using Symfony 7, if that information is necessary.
Thank you in advance for your assistance. I prefer maintaining a clean comments section and want to avoid cluttering it with unnecessary thank-you messages.
Best regards,
Easwaran Chinraj
Hey @Easwaran_Chinraj
Are you using Behat behind the scenes? You need to boot the Symfony's kernel on the "test" environment. Or, perhaps the problem is on the HTTP calls it makes to your application. If that's the case, you can set up the
APP_ENVenvironment variable at the time you start the web server, just like thisAPP_ENV=test symfony serve -dCheers!
Dear MolloKhan,
I followed your suggestion and tried running
symfony serve -d --env testin my Windows environment. However, I encountered the following error message:Incorrect usage: flag provided but not defined: -env.In light of your advice, I proceeded by copying the contents of the
.envfile to.env.localand adjusted theAPP_ENVvariable totest, which indeed resolved the issue.Interestingly, when I executed the migration command
symfony console doctrine:migrations:migrate --env=testwith the--envflag, it worked flawlessly. However, I'm puzzled as to whysymfony serve -d --env testfails with an error message.Could you please advise on the equivalent command for setting the environment to test while starting the server on Windows? Your assistance is greatly appreciated.
Thank you in advance.
Best regards,
Easwaran Chinraj
I don't know how to do it in Windows but I asked ChatGPT and said you can do this
I hope it helps!
Dear MolloKhan,
Thank you very much for your time, patience, and assistance. Running
set "APP_ENV=test"and then starting the server made the Selenium2 to use the test database.And thanks for this great tutorial series!
Cheers!
Awesome! You're welcome :)
Mine sometimes tries to fill out the name field WHILE the modal is loading, which then fails (because it's not visible yet). I was able to get it to pass every time by adding a second wait:
But I was wondering if there was a better way of handling this.
Hey Matt,
Looks like you wait 0.1 second, but not a big deal. Hm, this line should help: $('.modal:visible').length > 0 - probably you need to debug the HTML in a tool like Google Chrome toolbar, maybe you just need to use a different from ".modal" class, probably some parent tag is "display:none" as well.
Cheers!
"Houston: no signs of life"
Start the conversation!