I am using selenium server. Its working well to test an application running on port 80.
but if I test an application running on another port than 80, e.g. 5001, the connection is refused.
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities;
br = webdriver.Remote(command_executor="http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.CHROME)
br.get("http://127.0.0.1:5001/login/")
br.get_screenshot_as_file("/tmp/test.png")
I get the following screenshot:
How can I test on port 5001 ?
EDIT
I am running Selenium server as a Docker container with docker-compose:
version: '2'
services:
selenium:
image: selenium/standalone-chrome:latest
ports:
- 4444:4444
The Hub will listen to port 4444 by default. You can view the status of the hub by opening a browser window and navigating to http://localhost:4444/grid/console. To change the default port, you can add the optional -port flag with an integer representing the port to listen to when you run the command.
Step 3: Start Nodes To start nodes open the command prompt and navigate to the directory, where the Selenium Server Standalone jar file is stored. When -role option that is provided is not specified, and it is not the hub, the default port is 5555.
Selenium 4 is fully backward compatible with existing Selenium versions - you can migrate without compromising on the stability of your existing test cases.
You are running Selenium inside a Docker container. If you try to connect to localhost, that points to the Docker container itself.
You have to connect to your host like it is described here: How to access host port from docker container
Use your internal IP address or connect to the special DNS name
host.docker.internal
which will resolve to the internal IP address used by the host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With