Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom request header in Codeception #5308

Closed
markodemo1305 opened this issue Dec 24, 2018 · 2 comments
Closed

Add custom request header in Codeception #5308

markodemo1305 opened this issue Dec 24, 2018 · 2 comments

Comments

@markodemo1305
Copy link

Currently there is an issue for new Safari 11.1 browser and later that regular login parameters cannot be processed in format: "http(s)://user:pass@host".

There seems to be a way for bypassing this by sending customized request header in Selenium using WebDriverBackedSelenium class.

selenium = new WebDriverBackedSelenium(driver, "http://:@");
selenium.start("addCustomRequestHeader=true");
selenium.addCustomRequestHeader( "Authorization","Basic "+"YWRpZGFzOmFkaWRhczEyMyM=" );

Is theere a way to do this in PHP/Codeception? Since there is no WebDriverBackedSelenium class in codeception, is there some alternative to this which can be used, or some other way of doing this in efficient way?

@Naktibalda
Copy link
Member

There is no way to achieve this.
Codeception uses facebook/php-webdriver library for communicating with Selenium.
php-webdriver has no addCustomRequestHeader command and no plans to add it

the addCustomRequestHeaders capability was part of obsolete Selenium RC and is not part of Selenium WebDriver. There is long-standing policy of Selenium project to not manipulate the HTTP protocol itself by Selenium - only focus on emulating user actions. So if you really need this, you must take another approach, like BrowserMob proxy, browser extension etc. See eg. SeleniumHQ/selenium-google-code-issue-archive#2047

@c33s
Copy link
Contributor

c33s commented Mar 9, 2024

@Naktibalda still would be handy to be able to set request header for the symfony client which is capable of doing so. see https://symfony.com/doc/current/http_client.html#headers and Codeception/module-symfony#186

for regular cests you can do

$I->haveHttpHeader('Authorization', 'Bearer ABC');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants