Issue
I have installed selenium 4.6.0 in my local machine which works fine, within company VPN.
Then when I deployed it in our orgs kubernetes cluster (isolateComponents: true) I am getting HTTP 504 for my test cases.
No issues in the chrome node logs
Starting ChromeDriver 107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa-refs/branch-heads/5304@{#942}) on port 16517
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1670230314.770][SEVERE]: bind() failed: Cannot assign requested address (99)
08:51:54.972 INFO [LocalNode.newSession] - Session created by the Node. Id: 28c938ed7495ed7987bd6f37987e6f96, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 107.0.5304.87, chrome: {chromedriverVersion: 107.0.5304.62 (1eec40d3a576..., userDataDir: /tmp/.com.google.Chrome.QNhMmk}, goog:chromeOptions: {debuggerAddress: localhost:43699}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: http://localhost:43699, se:cdpVersion: 107.0.5304.87, se:vncEnabled: true, se:vncLocalAddress: ws://192.168.161.159:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
08:52:02.203 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://192.168.161.159:7900
But the router node I can see the below issue:
❯ kubectl logs selenium-router-7458b5ccbd-nb48c
2022-12-05 08:45:30,097 INFO Included extra file "/etc/supervisor/conf.d/selenium-grid-router.conf" during parsing
2022-12-05 08:45:30,100 INFO RPC interface 'supervisor' initialized
2022-12-05 08:45:30,100 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-12-05 08:45:30,100 INFO supervisord started with pid 7
2022-12-05 08:45:31,103 INFO spawned: 'selenium-grid-router' with pid 9
Starting Selenium Grid Router...
2022-12-05 08:45:31,106 INFO success: selenium-grid-router entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Tracing is disabled
08:45:31.432 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
08:45:31.437 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
08:45:32.323 INFO [RouterServer.execute] - Started Selenium Router 4.6.0 (revision 79f1c02ae20): http://192.168.175.198:4444
08:49:55.051 WARN [SimpleDataFetcherExceptionHandler.logException] - Exception while fetching data (/sessionsInfo) : java.net.ConnectException: Connection refused
java.io.UncheckedIOException: java.net.ConnectException: Connection refused
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:284)
at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
I have created the chrome node and router image with the following command for secure ssl connection to my website.
FROM selenium/node-chrome:107.0-chromedriver-107.0
USER root
ADD ssl.crt /usr/local/share/ca-certificates/ssl.crt
RUN update-ca-certificates
USER seluser
FROM FROM selenium/router:4.6.0
USER root
ADD ssl.crt /usr/local/share/ca-certificates/ssl.crt
RUN update-ca-certificates
USER seluser
Not able to understand the issue for the connection refusal, do I need to add proxy details? If so where can I add the same?
Solution
The networking was not the issue as I could curl the url from the chrome node easily without delay. The Issue was proxy , that i had to pass from my client code. I am using serenity and adding the below to the serenity property has no effect
serenity.proxy.http="abcd:1234"
serenity.proxy.sslProxy="abcd:1234"
serenity.proxy.noProxy="localhost,127.0.0.1,192.168.0.0/16,.....l"
Hence, I had to create a custom class like below
public class CustomCapabilityEnhancer implements BeforeAWebdriverScenario {
@Override
public MutableCapabilities apply(EnvironmentVariables environmentVariables, SupportedWebDriver driver, TestOutcome testOutcome, MutableCapabilities capabilities) {
Proxy proxy = new Proxy();
proxy.setHttpProxy("abcd:1234");
proxy.setSslProxy("abcd:1234");
proxy.setNoProxy("localhost,127.0.0.1,192.168.0.0/16,....");
ChromeOptions options = new ChromeOptions();
options.setProxy(proxy);
options.setAcceptInsecureCerts(true);
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
return capabilities; }
@Override
public boolean isActivated(EnvironmentVariables environmentVariables) {
return true;
}
}
and in the serenity property I had to add the package name where the above code reside
serenity.extension.packages=com.mytest.org.application.features.ui.utils
Answered By - Susanta Adhikary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.