I am trying to get Selenium Web Driver to work with php using the Yii framework.
phpunit is installed and working.
I have the latest version of selenium server running. (selenium-server-standalone-2.37.0.jar)
I have this Yii extension for web driver installed.
I have this shell test.
Yii::import('ext.webdriver-bindings.CWebDriverDbTestCase');
class SiteTest extends CWebDriverDbTestCase
{
public function testExample() {
$this->get("http://www.example.com");
$this->assertTrue($this->isTextPresent('Example Domain'));
$this->assertTrue(true);
}
}
When I run it on the command line with
phpunit functional/SiteTest.php
The test runs. A firefox window opens with an empty profile (with the web driver plugin installed.) But the webpage doesn't load. There is nothing in the address bar. Nothing happens at all. The browser stays open, meanwhile the command line prints the following.
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from C:\full\path\to\yii\project\protected\tests\phpunit.xml
F
Time: 4.88 seconds, Memory: 3.50Mb
There was 1 failure:
1) SiteTest::testExample
Failed asserting that false is true.
C:\full\path\to\yii\project\protected\tests\functional\SiteTest.php:18
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
I'm on windows 7 and have tried turning off the firewall to see if that was the cause.
As you can see phpunit is working fine as the second test passes. But for some reason firefox is not opening the requested page.
Edit: I'm using the latest release of php (5.5.5)
Edit: I've now also tried with the Chrome Driver. I get the same result. Chrome opens but the page does not load. The address bar just has 'data:,' in it.
I have the same issue whenever I launch my scripts with the newest server nothing happens. But I noticed that if I use selenium server v2.33 everything works again (http://goo.gl/cxpyd2). However, I have been getting a execute js error that appears to happen with the new firefox and with 2.33? I am not sure. So I assume that it was fixed with the newer version of the server but I am not able to try it.
I experienced the same problem however downgrading the firefox version to 11.0 it started working. If you use linux you can use synaptic and force a firefox version downgrade
Related
I created a new project using Symfony 5.1.2, then I tried to run the server using
symfony serve. Once I tried to access localhost:8000, I had this warning in the terminal : [Web Server/PHP ] Jun 22 13:47:55 |WARN | SERVER GET (404) / ip="::1".
Moreover, the page I had was symfony's default page saying "#Page not found".
I checked the existing routes and I had default ANY ANY ANY /.
I also checked the DefaultController, but everything looks fine, since it is the auto generated controller...
I don't know what else to check, how could I get this default page working ?
I had a similar issue : I had run symfony server:start and was even seeing it react to my entering HTTP addresses in the browser, but I kept having that "# Page not found" message.
Quite simply, my symfony project was in Group/SubGroup/Project... and I was running symfony server:start from Group/SubGroup. When I stopped Symfony and ran it again from Group/SubGroup/Project, it worked like a charm.
A beginner's mistake, to be sure, but beginners use this site too.
Did you run the symfony project? It will show if you didn't run the symfony project. Run the project from terminal.
cd my-project/
symfony server:start
ip="::1" is the localhost on windows and wsl 2. Symfony server listen on 127.0.0.1:8000.
You must edit the windows hosts file at C:\Windows\System32\drivers\etc\hosts.
Add this line : 127.0.0.1:8000 localhost:8000
It works for me.
i am using Codeception for acceptance testing. On my local pc i have no problems to run the tests with selenium and chromedriver. Until 1 week, it works also fine at my git, but now, there comes this error.
"[PHPUnit\Framework\Exception] Undefined index: ELEMENT"
local it is working fine without errors.
I already searched this error and found an tip, that i have to start selenium with "-enablepassthrough false". But this does not really works.
Before 1 week with all the same setup, it works fine.
this is my acceptance.suite.yml:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'https://website.com'
host: 'selenium__standalone-chrome'
port: 4444
browser: chrome
window_size: 1920x1080
For Chrome/ChromeDriver v79 setting w3c to false in acceptance.suite.yml helped:
modules:
enabled:
- WebDriver:
capabilities:
chromeOptions:
w3c: false
This error message...
[PHPUnit\Framework\Exception] Undefined index: ELEMENT
...implies that the ChromeDriver's click() through Codeception is having an issue.
As per #reinholdfuereder's comment within the discussion facebook/php-webdriver - W3C WebDriver protocol support:
When using default W3C protocol, then the Codeception (v2.5.6) test fails with Undefined index: ELEMENT in waitForElement() operation.
When using legacy protocol, then the test succeeds for waitForElement() operation, which is followed by a seemingly also successful click() operation, but fails in the waitForElementNotVisible() operation.
Codeception's click() operation is translated into clickElement WebDriver command that is seemingly no more supported by ChromeDriver v75.
Solution
If you are using ChromeDriver v75.x and Chromium v75.x and you are seeing this error, you need to pass an additional chromeOptions w3c set to true.
Outro
You can find a couple of detailed discussion in:
How to turn off w3c in chromedriver to address the error unknown command: Cannot call non W3C standard command while in W3C
Cannot call non W3C standard command while in W3C mode (Selenium::WebDriver::Error::UnknownCommandError) with Selenium ChromeDriver in Cucumber Ruby
As #DebanjanB explained, setting the said option is a solution and this is what you get by updating facebook/php-webdriver to version >= 1.7.0
I think an even more solid solution (or habit) for your application is to use a specific docker image.
Your yaml makes me guess that you're using the selenium/standalone-chrome docker image. With their latest release (3.141.59-palladium) they updated the included Chrome version from 74 to 75 (see: https://github.com/SeleniumHQ/docker-selenium/releases).
Your local machine probably still runs an older version with Chrome 74 so no problems there. But whenever you rebuild the docker machine (e.g. when using some CI environment) you get the latest version. In this case a new Chrome version. Which "forces" you to also upgrade your php machine with a new facebook/php-webdriver.
I'd suggest to specify a version of the image to prevent these unwanted side effects, like
image: selenium/standalone-chrome:3.141.59-oxygen
or, if you've already made it run with Chrome 75, 3.141.59-palladium.
Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.
The elasticSearch runs fine on my centos as a non-service. I run it as "sh bin/elasticsearch". The client I installed using composer is PHP v2.0. It just won't do anything it used to do before. I used this before and I could search, index documents, make index. Right now I cannot do anything because of this error. The strangest thing is that ElasticSearch seems to be running fine, and I can also call it with curl like:
curl localhost:9200
Please advise on the PHP API failure? I tried:
1. Opening port 9200 on my centos 6 for all
2. Used every method from the book in PHP API: search, index, delete index, etc...always get the same result and an exception is thrown in the Elasticsearch/Client class:
“No alive nodes found in your cluster”
3. Changed the owner of the directory nodes to centos, apache, elasticsearch - no use.
Resolved by installing a fresh latest tarball elasticsearch server and running it straight like this: sh bin/elasticsearch.
When I try to use SoapClient:
try {
$client = new SoapClient('http://someurl/somefile.wsdl');
} catch (SoapFault $e) {
var_dump($e);
}
I have catch error with:
["faultstring"] => "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://someurl/somefile.wsdl' : failed to load external entity "http://someurl/somefile.wsdl"
["faultcode"] => "WSDL"
I can manually download http://someurl/somefile.wsdl and can file_get_contents for this file. I try to use it before on different computer and it worked. Possible problem with php or apache settings..
ArchLinux with last updates for php and apache. I tried to enable all php extensions.
Were you able to get wsdl using file_get_contents() in browser?
I had similar issue recently in Archlinux with same faultstring, no matter what wsdl file was used. The same code was working without any problem on other Archlinux machine and Windows XP box.
After some research, it came out that problem arose only when I tried to access the page in browser - script accessed from command line worked as expected. Then I changed the script to download the wsdl file directly, using aforementioned file_get_contents() - it gave me a warning "php_network_getaddresses: getaddrinfo failed: Name or service not known".
Few tutorials (on SO, or this one: http://albertech.net/2011/05/fix-php_network_getaddresses-getaddrinfo-failed-name-or-service-not-known/ ) later I haven't fought off the problem yet. But then I discovered what introduced the issues: I had been running NetworkManager since the installation of Arch (to better handle wireless), and few weeks later I've added mysqld and httpd as last to DAEMONS section in rc.conf - it seems this broke DNS resolution for apache.
Having two solutions (go back to starting servers manually or try other network manager) I've switched to wicd and haven't run into the issue again.