panther
panther copied to clipboard
Chrome terminates before pressing a key....
Hello good,
Panther with options --debug PANTHER_NO_HEADLESS = 1 does it work without symfony?
Everything is correct, but Chrome terminates before pressing a key.
Check here: https://ibb.co/8rQ62k7
My Test Code:
class arraysTest extends TestCase
{
public function it_should_return_the_first_key()
{
$client = Client::createChromeClient(null);
$crawler = $client->request('GET', 'https://www.test.com');
$crawler->findElement(WebDriverBy::cssSelector('#buscar2'))->sendKeys('hola')->submit();
}
}
any solution?
Thank you!
The error message says that element #buscar2
cannot be found. Are you sure that you GET the correct webpage (it shows data:
in the browser's url) and that the element exists?
@DeveloperPad The element does not exist, I force the test to fail.
Panther with options PANTHER_NO_HEADLESS = 1 --debug
Chrome should terminate only by pressing a key ...
Check here: https://youtu.be/hJqQNKHvHBw?t=707
Thank you!
@keldrox can you paste whole output of command so people can see what is the whole error? (instead of only partial screeenshot / gif)
Do you try to use this feature? https://github.com/symfony/panther#interactive-mode
Hi! @domis86
Command output env | grep PAN
PANTHER_NO_SANDBOX=1
PANTHER_NO_HEADLESS=1
PANTHER_CHROME_ARGUMENTS=--disable-dev-shm-usage --no-sandbox --display=host.docker.internal:0.0 --disable-gpu --disable-extensions --remote-debugging-port=9222
File test. I don't use Symfony extends PantherTestCase
<?php
declare (strict_types=1);
use Facebook\WebDriver\WebDriverBy;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Panther\Client;
class pantherTest extends TestCase
{
/** @test */
public function it_should_return_the_first_key()
{
$client = Client::createChromeClient(null);
$crawler = $client->request('GET', 'https://www.test.loc');
$crawler->findElement(WebDriverBy::cssSelector('#buscar2'))->sendKeys('hola')->submit();
}
}
Command to launch the tests
./includes/vendor/bin/phpunit --debug
Exit before pressing a key. Chrome has already been closed
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Test 'pantherTest::it_should_return_the_first_key' started
Error: stale element reference: element is not attached to the page document
(Session info: chrome=96.0.4664.45)
Press enter to continue...
Full output
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Test 'pantherTest::it_should_return_the_first_key' started
Error: stale element reference: element is not attached to the page document
(Session info: chrome=96.0.4664.45)
Press enter to continue...
Test 'pantherTest::it_should_return_the_first_key' ended
Time: 04:01.671, Memory: 10.00 MB
There was 1 error:
1) pantherTest::it_should_return_the_first_key
Facebook\WebDriver\Exception\StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=96.0.4664.45)
/shared/httpd/includes/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:127
/shared/httpd/includes/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:372
/shared/httpd/includes/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:585
/shared/httpd/includes/vendor/php-webdriver/webdriver/lib/Remote/RemoteExecuteMethod.php:27
/shared/httpd/includes/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebElement.php:102
/shared/httpd/includes/vendor/symfony/panther/src/DomCrawler/Crawler.php:481
/shared/httpd/tests/pantherTest.php:21
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
ERROR: 2
make: *** [Makefile:74: unit-test] Error 2
Thank you!
@jose-sampedro do you also registered this extension as mentioned in: https://github.com/symfony/panther#interactive-mode
To use the interactive mode, the PHPUnit extension must be registered.