I
I
ideological2017-02-28 07:50:42
PHP
ideological, 2017-02-28 07:50:42

How to send cookie to facebook/php-webdriver?

Hi,
I'm using facebook/php-webdriver
and everything is fine until I get to adding cookies.
Standard example https://github.com/facebook/php-webdriver/blob/com...

$cookie = new Cookie('cookie_name', 'cookie_value');
$driver->manage()->addCookie($cookie);

will give a logical error "Class 'Facebook\\WebDriver\\Cookie' not found". Everything works without this part.
Does such a Cookie class even exist in the library (I didn't find it)? How to register it in use?
Please tell me a working example of adding a cookie. ;) I did not find any examples with cookies in the
github wiki . :(

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ideological, 2017-02-28
@ideological

Now I read the question-answer https://github.com/facebook/php-webdriver/issues/401 and they write there that cookies can only be set for an open domain. And it's not cool.
Solved my problem myself.
By using custom profile substitution.

$options->addArguments(array('user-data-dir=/chrome/temp_profile'));

L
Light_Metal, 2017-07-31
@Light_Metal

Does such a Cookie class even exist in the library (I didn't find it)?

The Cookie class is in the community branch.
https://github.com/facebook/php-webdriver/blob/com...
The same project on GitHub from which the example code is taken. Those. this same project should be used instead of the official version from facebook

D
Dmitry, 2020-01-19
@windd

this code works for me, but in this form:
$cookie = new \Facebook\WebDriver\ Cookie('cookie_name', 'cookie_value');
$driver->manage()->addCookie($cookie);
$cookies = $driver->manage()->getCookies();
pay attention to your namespace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question