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

selenium/standalone-chrome:4.0.0: “Host header or origin header is specified and is not localhost” #8325

Closed
devopsix opened this issue May 19, 2020 · 3 comments

Comments

@devopsix
Copy link

🐛 Bug Report

Remote WebDriver fails to execute any command through a Selenium 4.0.0 Standalone Server in Chrome if any other (non IP address) hostname than “localhost” is used for connecting to the Selenium Server.

Having URLs with other names than “localhost” for the host part is a very common scenario in a containerized environment. Using IP addresses ususally is not an option in environments as dynamic as e.g. a Kuberneter cluster.

The root cause may be related to this Chromium issue.

Detailed steps to reproduce the behavior:

This issue can be reproduced by running basic remote WebDriver commands against a selenium/standalone-chrome:4.0.0 Docker container.

Given you have Docker installed and you have unpacked the attached
selenium.zip file.

  1. Open a shell.
  2. Run docker-compose up -d.
  3. Run docker-compose run client python /selenium4.py.
Traceback (most recent call last):
File "/selenium4.py", line 7, in <module>
  driver.get("http://www.google.com")
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
  self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
  self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response
  raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Host header or origin header is specified and is not localhost.

For demonstrating that this is not an issue with selenium/standalone-chrome:3.141.59, run: docker-compose run client python /selenium3.py.

[<selenium.webdriver.remote.webelement.WebElement (session="1d881a973e913012aab4f7ae2d64bdf7", element="81cb5c16-5461-4378-b7fb-581f591afc04")>]

The commands in selenium3.py and selenium4.py are as simple as:

driver.get("http://www.google.com")
print(driver.find_elements_by_tag_name("body"))

Expected behavior

selenium4.py should complete successfully.

selenium4.py does complete successfully when being run from the host machine (given Python is installed) with http://localhost:4444, resp. as the Selenium Server URL.

Environment

Browser: Chrome
Browser Version: The one included with selenium/standalone-chrome:4.0.0
Selenium Grid version: 4.0.0

@ghost
Copy link

ghost commented May 19, 2020

👋 Hi there! Thank you for creating this issue.

I am the Selenium Assistant Bot 🤖, I triage issues in this repository. If I can't do it, I label it to help maintainers identify issues that need triaging.

I am an Open Source project 🙌, post bugs or ideas here!

@ghost
Copy link

ghost commented May 19, 2020

❗️ It seems this issue is not using any of the supported templates

💡 Supported issue types are (they start with):

  • 🐛 Bug Report (bugs found in a recent release)
  • 🚀 Feature Proposal (a useful feature you would like to propose)
  • 💥 Regression Report (a supported feature is not working anymore)

Issue templates help this project to stay in shape, please use them and fill them out completely. By doing that you are helping the project because the community and maintainers can provide prompt feedback, and potentially solve the issue.

If you are asking a question, a better way to address this is:

If you think this is incorrect, please feel free to open a new issue.

Thank you for your contributions.

@ghost ghost closed this as completed May 19, 2020
@devopsix
Copy link
Author

Hmpf, using # instead of ## seems to make the bot fail to recognize the issue type. Reopened as #8326.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant