Closed maheshdaniin closed 6 months ago
This isn't an axe-core issue. Would you mind opening this issue here instead: https://github.com/dequelabs/axe-core-maven-html/issues
I can go ahead and transfer the issue for you
Thanks for transferring the issue.. looking forward to fix
Hey @maheshdaniin,
Would you be able to provide a bit more context on how your test is set up?
Using the below example, I was not able to replicate this issue:
WebDriver driver = new FirefoxDriver();
AxeBuilder builder = new AxeBuilder();
driver.get("https://dequeuniversity.com/demo/mars/");
Results results = builder.analyze(driver);
List<Rule> violations = results.getViolations();
for (Rule rule : violations) {
System.out.printf("Rule: %s - Desc: %s%n", rule.getId(), rule.getHelp());
}
driver.quit();
Output:
Rule: aria-allowed-attr - Desc: Elements must only use allowed ARIA attributes
Rule: button-name - Desc: Buttons must have discernible text
Rule: color-contrast - Desc: Elements must meet minimum color contrast ratio thresholds
Rule: duplicate-id-active - Desc: IDs of active elements must be unique
Rule: duplicate-id-aria - Desc: IDs used in ARIA and labels must be unique
Rule: duplicate-id - Desc: id attribute value must be unique
Rule: frame-title - Desc: Frames must have an accessible name
Rule: html-has-lang - Desc: <html> element must have a lang attribute
Rule: image-alt - Desc: Images must have alternate text
Rule: landmark-unique - Desc: Ensures landmarks are unique
Rule: link-name - Desc: Links must have discernible text
Rule: region - Desc: All page content should be contained by landmarks
Rule: select-name - Desc: Select element must have an accessible name
Rule: tabindex - Desc: Elements should not have tabindex greater than zero
Hello @Zidious ,
parentHandle = driver.getWindowHandle();
String uniqueKey = buildUniqueKey(driver);
AxeRunOnlyOptions runOnlyOptions = new AxeRunOnlyOptions();
runOnlyOptions.setType("tag");
runOnlyOptions.setValues(axeStandards);
AxeRunOptions options = new AxeRunOptions();
options.setRunOnly(runOnlyOptions);
AxeBuilder axe = new AxeBuilder().withOptions(options);
Results result = axe.analyze(driver, false);
List<Rule> axeViolations = result.getViolations();
List<Rule> axeIncomplete = result.getIncomplete();
driver is set using serenity selenium package
This code gets triggered on navigation event afterGet
Also Running firefox driver with following options
private FirefoxOptions getDefaultFirefoxOptions() {
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
options.setAcceptInsecureCerts(false);
options.addArguments("-allow-origins");
options.setCapability("webSocketUrl", true);
// options.addArguments("-remote-allow-origins"); options.addArguments("-no-sandbox"); options.addArguments("-disable-dev-shm-usage"); options.addArguments("-allow-host=localhost"); if ("true".equalsIgnoreCase(Configuration.get("ignore_certificate_errors"))) { options.setAcceptInsecureCerts(true); LOGGER.info("Test is ignoring invalid certificates"); }
if (!firefoxOptionsArguments.isEmpty()) {
LOGGER.debug("FIREFOX OPTIONS ARGUMENTS: ----- {}", firefoxOptionsArguments.toString());
options.addArguments(firefoxOptionsArguments);
}
if (!firefoxOptionsHeaders.isEmpty()) {
LOGGER.debug("FIREFOX OPTIONS HEADERS: ----- {}", firefoxOptionsHeaders.toString());
options.addArguments(firefoxOptionsHeaders);
}
return options;
}
And firefoxOptionsArguments and firefoxOptionsHeaders is empty..
Product
axe-core
Product Version
4.7.0
Latest Version
* [x] I have tested the issue with the latest version of the product
Issue Description
Hello, Seeing this error on firefox driver with AXE core where in websocket connection is not established.
raised bug with firefox webdriver mozilla/geckodriver#2117 They are suggesting that make sure that the client sets the correct value for the origin header or doesn't provide it at all.
as suggested by following error.
1685720362480 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:59534 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:64282/ Jun 02, 2023 4:39:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
Full stack trace:
Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Build info: version: '4.0.0', revision: '3a21814679' System info: host: 'MacBook-Pro.local', ip: 'xxx.xxx.xx.xx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.3.1', java.version: '17.0.5' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.(NettyWebSocket.java:104) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:137) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:127) at org.openqa.selenium.devtools.Connection.(Connection.java:77) at org.openqa.selenium.firefox.FirefoxDriver.maybeGetDevTools(FirefoxDriver.java:359) at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:441) at com.deque.html.axecore.extensions.WebDriverExtensions.closeAboutBlank(WebDriverExtensions.java:146) at com.deque.html.axecore.selenium.AxeBuilder.analyzePost43x(AxeBuilder.java:782) at com.deque.html.axecore.selenium.AxeBuilder.analyzeRawContext(AxeBuilder.java:652) at com.deque.html.axecore.selenium.AxeBuilder.analyze(AxeBuilder.java:624) at xx.xxx.xx.xxx.accessibility.AccessibilityWrapper.checkPageForAccessibility(AccessibilityWrapper.java:73) at xx.xxx.xx.xxx.accessibility.BrowserListener.afterGet(BrowserListener.java:23) ... 68 more
complete log : -
5720356999 geckodriver INFO Listening on 127.0.0.1:57438 1685720357260 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "--marionette" "-headless" "-allow-origins" "-no-sand ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/8d/wg845lkj6q54nvg5hfglhbjh0000gq/T/rust_mozprofile4GVRD6" *** You are running in headless mode. console.warn: services.settings: Ignoring preference override of remote settings server console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment 1685720358375 Marionette INFO Marionette enabled 1685720358517 Marionette INFO Listening on port 59507 console.error: "Warning: unrecognized command line flag -allow-origins\n" console.error: "Warning: unrecognized command line flag -disable-dev-shm-usage\n" console.error: "Warning: unrecognized command line flag -remote-allow-hosts\n" Read port: 59507 WebDriver BiDi listening on ws://127.0.0.1:64282 [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /var/folders/8d/wg845lkj6q54nvg5hfglhbjh0000gq/T/rust_mozprofile4GVRD6/search.json.mozlz4", (void 0))) DevTools listening on ws://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Jun 02, 2023 4:39:20 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C 1685720362480 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:59534 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:64282/ Jun 02, 2023 4:39:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Invalid Status code=400 text=Bad Request java.io.IOException: Invalid Status code=400 text=Bad Request at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92) at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118) at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833)
Jun 02, 2023 4:39:22 PM org.openqa.selenium.support.events.EventFiringDecorator callListenerMethod WARNING: null java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.openqa.selenium.support.events.EventFiringDecorator.callListenerMethod(EventFiringDecorator.java:311) at org.openqa.selenium.support.events.EventFiringDecorator.fireAfterEvents(EventFiringDecorator.java:252) at org.openqa.selenium.support.events.EventFiringDecorator.lambda$afterCall$1(EventFiringDecorator.java:177) at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4204) at org.openqa.selenium.support.events.EventFiringDecorator.afterCall(EventFiringDecorator.java:177) at org.openqa.selenium.support.decorators.DefaultDecorated.afterCall(DefaultDecorated.java:53) at org.openqa.selenium.support.decorators.WebDriverDecorator.lambda$createProxy$0(WebDriverDecorator.java:295) at jdk.proxy2/jdk.proxy2.$Proxy43.get(Unknown Source) at net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:172) at net.serenitybdd.core.pages.PageObject.openPageAtUrl(PageObject.java:981) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:879) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:867) at xx.xxx.xx.domain.component.ui.stepLib.UiStepLib.navigateToxxxxPage(UiStepLib.java:40) at xx.xx.xx.domain.component.ui.stepLib.UiStepLib$ByteBuddy$fuDTSiIN.navigateToxxxxPage$accessor$1Lht6Qop(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:504) at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:484) at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:458) at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:210) at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:197) at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:85) at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51) at xx.xxx.xx.domain.component.ui.stepLib.UiStepLib$ByteBuddy$fuDTSiIN.navigateToxxxxPage(Unknown Source) at xx.xxx.xx.domain.component.ui.steps.StepDefinitions.iOpenGoogle(StepDefinitions.java:29) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.cucumber.java.Invoker.doInvoke(Invoker.java:66) at io.cucumber.java.Invoker.invoke(Invoker.java:24) at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47) at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29) at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66) at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63) at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10) at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92) at io.cucumber.core.runner.TestStep.run(TestStep.java:64) at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51) at io.cucumber.core.runner.TestCase.run(TestCase.java:104) at io.cucumber.core.runner.Runner.runPickle(Runner.java:73) at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110) at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117) at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123) at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:200) at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at io.cucumber.core.runtime.Runtime.run(Runtime.java:87) at net.serenitybdd.cucumber.cli.Main.run(Main.java:27) at net.serenitybdd.cucumber.cli.Main.main(Main.java:18) Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Build info: version: '4.0.0', revision: '3a21814679' System info: host: 'MacBook-Pro.local', ip: 'xxx.xxxx.xx.xx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.3.1', java.version: '17.0.5' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.(NettyWebSocket.java:104) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:137) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:127) at org.openqa.selenium.devtools.Connection.(Connection.java:77) at org.openqa.selenium.firefox.FirefoxDriver.maybeGetDevTools(FirefoxDriver.java:359) at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:441) at com.deque.html.axecore.extensions.WebDriverExtensions.closeAboutBlank(WebDriverExtensions.java:146) at com.deque.html.axecore.selenium.AxeBuilder.analyzePost43x(AxeBuilder.java:782) at com.deque.html.axecore.selenium.AxeBuilder.analyzeRawContext(AxeBuilder.java:652) at com.deque.html.axecore.selenium.AxeBuilder.analyze(AxeBuilder.java:624) at xx.xxx.xx.xxx.accessibility.AccessibilityWrapper.checkPageForAccessibility(AccessibilityWrapper.java:73) at xx.xxx.xx.xxx.accessibility.BrowserListener.afterGet(BrowserListener.java:23) ... 68 more
@
that all 👍👍``
Everything right all working together trust me please
Looking more at the stack-trace, there are few things I've noticed and I'm leaning more towards the Selenium Firefox driver/ configuration than the selenium axe-core integration. Your Firefox options are not correctly set, looking at the stack:
console.error: "Warning: unrecognized command line flag -allow-origins\n"
console.error: "Warning: unrecognized command line flag -disable-dev-shm-usage\n"
console.error: "Warning: unrecognized command line flag -remote-allow-hosts\n"
Flags should be denoted --allow-origins
. This may/may not be related to this stack error:
1685720362480 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:59534
JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:64282/
Jun 02, 2023 4:39:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Invalid Status code=400 text=Bad Request
java.io.IOException: Invalid Status code=400 text=Bad Request
at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92)
In your analyze()
command, you can simply call Results result = axe.analyze(driver);
.
ok.. let me try with that.. analyze() command, you can simply call Results result = axe.analyze(driver);. is that true for all brower type I use?
I tried with with and also tried disabling all the firefox options I am setting still seeing same issue. with all firefox options were disabled I could see firefox window opened and after navigate it tried to open in about:blank tab and then it failed as axe code tries to close about:blank tab and it can't get hold of it.
Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:51726/devtools/browser/35bfddc1-40f0-4a3e-a10a-20e135963144
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: 'MacBook-Pro.local', ip: '192.168.0.29', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.3.1', java.version: '17.0.5'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.http.netty.NettyWebSocket.
which is part of full stack trace I posted in the beginning.
Correct, we open a blank tab to complete the analysis.
I'd like to dig a bit more into debugging this because I cannot replicate it using the example test case.
ok.. let me create a sample project and share it with you
sample-project.zip attached is the sample project @Zidious This requires firefox and compatible driver executable in system path
We can still see following error 1686326362391 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:61663 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:56224 16:59:22.395 [AsyncHttpClient-1-4] DEBUG org.asynchttpclient.netty.handler.WebSocketHandler -
Request DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE) GET /devtools/browser/c5599ed9-e8db-4d81-9e9d-037b06611b52 HTTP/1.1 upgrade: websocket connection: upgrade sec-websocket-key: E+JIdIUJQPTS/aYcBaRFmQ== sec-websocket-version: 13 origin: http://127.0.0.1:56224 host: 127.0.0.1:56224 accept: / user-agent: AHC/2.1
Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1) HTTP/1.1 400 Bad Request Server: httpd.js Content-Type: text/plain content-length: 72
Jun 09, 2023 4:59:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Invalid Status code=400 text=Bad Request java.io.IOException: Invalid Status code=400 text=Bad Request
Sorry to be a pain @maheshdaniin - due to security reasons I cannot download that provided ZIP. Please open a example repository and share the link. I can investigate further.
@Zidious please use this repo https://github.com/maheshdaniin/sample-project
@maheshdaniin I am currently on PTO and will investigate further on Monday.
Thanks for providing the repository
Edit: I've been heads down doing other work @maheshdaniin - I will get to this tomorrow (Friday 23rd June) and the weekend - apologies
Hey @maheshdaniin,
After looking at your sample project I see you've defined checkPageForAccessibility
. But In your test UI test it doesn't get called.
Most likely, you will need to define a accessibility step in your step configurations file for Serenity, it looks like they are using Selenium under the hood. As stated before running selenium directly with Firefox reports no issues.
@Zidious The browser listener class is responsible for making this call checkPageForAccessibility
https://github.com/maheshdaniin/sample-project/blob/main/src/main/java/sample/project/domain/component/accessibility/BrowserListener.java
so after get and after click events are responsible to make a call to this method by using same current driver object.
so be assured that checkPageForAccessibility
method is getting called,
we implemented this in this way because then same ui test can be used for accessibility validation.
you can download this project locally and should be able to replicate this issue.
And yes, serenity uses selenium under the hood
Hello @Zidious
any view on above?
so selenium page events triggers checkPageForAccessibility
as suggested above
Hey @maheshdaniin,
After looking at this, it doesn't appear to be erroring out with Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to
but it appears to be erroring out on a test case, the other two cases were skipped:
classpath:features/ui/govUkSearching.feature:13 # Searching for Citizen in gov.uk home page
1 Scenarios (1 failed)
5 Steps (1 failed, 2 skipped, 2 passed)
0m10.083s
org.openqa.selenium.NoSuchElementException: Timed out after 2 seconds. Element not found
Specifically:
at sample.project.domain.component.ui.pages.GovHomePage.Search(GovHomePage.java:18)
at sample.project.domain.component.ui.stepLib.UiStepLib.searchForTerm(UiStepLib.java:30)
My assumption you're testing this on localhost? As I had to disable these Firefox options . To run on this sample, I removed all of the unnecessary options:
private FirefoxOptions getDefaultFirefoxOptions() {
FirefoxOptions options = new FirefoxOptions();
if ("true".equalsIgnoreCase(Configuration.get("ignore_certificate_errors"))) {
options.setAcceptInsecureCerts(true);
LOGGER.info("Test is ignoring invalid certificates");
}
return options;
}
I would suggest trying instead of implementing your own BrowserListener
by extending WebDriverListener
. To narrow things down and have a step definition, and a test sample that looks something like:
@ui
Feature: UI Test
Rule: Example Rule 1
Scenario Outline: Searching for Citizen in gov.uk home page
Given I use the <browser> browser
And I open Gov.uk home page
Then scan for accessibility
....
Examples:
| browser |
| firefox |
Additionally - what happens when you use Serenity's default driver, using both Firefox and Chrome? I see there a custom implementation of the driver within the properties file.
@Zidious looks like you are not able to go to the required page or url, hence no such element exception I can try two thing.. use different public website also try and use accessibility step as you mentioned instead of event trigger. Please give me some time, I will update soon.
@Zidious I tried locally with step definition function that manually calls as
searchResultPage.runAccessibilityChecks();
}
and this is still giving me same issue
I have pushed updated code here
https://github.com/maheshdaniin/sample-project/blob/main/src/main/resources/features/ui/govUkSearching.feature
Also tried with google search, I am seeing same error.
Hey @maheshdaniin,
I can take another look today.
@maheshdaniin,
So it looks like Serenity doesn't like the fact we open a blank tab. This is required for analyze()
(see finishRun).
The test appears to move onto the next definition before we are able to close the blank page.
Hello @Zidious This works fine with chromedriver used as provided driver class.. we have lots of tests running in chromdriver accessibility and that is working fine no issues. Let me try with default firefox.
@Zidious I have updated serenity.properties to use default firefox driver and throws same error
webdriver.driver=firefox
1690471863433 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:55526 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:49664 16:31:03.436 [AsyncHttpClient-1-4] DEBUG org.asynchttpclient.netty.handler.WebSocketHandler -
Request DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE) GET /devtools/browser/9d1b75b0-620b-4e4c-90e2-6a1f1a23a9d9 HTTP/1.1 upgrade: websocket connection: upgrade sec-websocket-key: Rrq44R34IYTbr1YwLJ7f3Q== sec-websocket-version: 13 origin: http://127.0.0.1:49664 host: 127.0.0.1:49664 accept: / user-agent: AHC/2.1
Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1) HTTP/1.1 400 Bad Request Server: httpd.js Content-Type: text/plain content-length: 72
Jul 27, 2023 4:31:03 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Invalid Status code=400 text=Bad Request java.io.IOException: Invalid Status code=400 text=Bad Request
Step failed
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:60845/devtools/browser/e6939fb7-2dcc-4e14-8ec2-d97eb1ea69c1
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: 'MacBook-Pro.local', ip: '192.168.0.29', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.5', java.version: '11.0.15.1'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.http.netty.NettyWebSocket.
Step failed
org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:60845/devtools/browser/e6939fb7-2dcc-4e14-8ec2-d97eb1ea69c1
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: 'MacBook-Pro.local', ip: '192.168.0.29', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.5', java.version: '11.0.15.1'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.http.netty.NettyWebSocket.
Interesting, I am leaning towards my previous comment, if Serenity works with Chromedriver I would suggest using that.
The default geckodriver with pure Selenium works as intended. It appears that Serenity does not like we open a blank new tab as part of the Selenium driver (outside of Senerity) as well as not allowing enough time to close the page before going onto the next definition.
@Zidious thanks for your updates on this issue.. I will try an raise issue with Serenity, to understand with them why this is happening.
@Zidious raise this issue with Serenity-bdd https://github.com/serenity-bdd/serenity-core/issues/3224
Closing - feel free to re-open if required.
Product
axe-core
Product Version
4.7.0
Latest Version
Issue Description
Hello, Seeing this error on firefox driver with AXE core where in websocket connection is not established.
raised bug with firefox webdriver https://github.com/mozilla/geckodriver/issues/2117 They are suggesting that make sure that the client sets the correct value for the origin header or doesn't provide it at all.
as suggested by following error.
1685720362480 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:59534 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:64282/ Jun 02, 2023 4:39:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
Full stack trace:
Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Build info: version: '4.0.0', revision: '3a21814679' System info: host: 'MacBook-Pro.local', ip: 'xxx.xxx.xx.xx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.3.1', java.version: '17.0.5' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.(NettyWebSocket.java:104) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:137) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:127) at org.openqa.selenium.devtools.Connection.(Connection.java:77) at org.openqa.selenium.firefox.FirefoxDriver.maybeGetDevTools(FirefoxDriver.java:359) at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:441) at com.deque.html.axecore.extensions.WebDriverExtensions.closeAboutBlank(WebDriverExtensions.java:146) at com.deque.html.axecore.selenium.AxeBuilder.analyzePost43x(AxeBuilder.java:782) at com.deque.html.axecore.selenium.AxeBuilder.analyzeRawContext(AxeBuilder.java:652) at com.deque.html.axecore.selenium.AxeBuilder.analyze(AxeBuilder.java:624) at xx.xxx.xx.xxx.accessibility.AccessibilityWrapper.checkPageForAccessibility(AccessibilityWrapper.java:73) at xx.xxx.xx.xxx.accessibility.BrowserListener.afterGet(BrowserListener.java:23) ... 68 more
complete log : -
5720356999 geckodriver INFO Listening on 127.0.0.1:57438 1685720357260 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "--marionette" "-headless" "-allow-origins" "-no-sand ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/8d/wg845lkj6q54nvg5hfglhbjh0000gq/T/rust_mozprofile4GVRD6" *** You are running in headless mode. console.warn: services.settings: Ignoring preference override of remote settings server console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment 1685720358375 Marionette INFO Marionette enabled 1685720358517 Marionette INFO Listening on port 59507 console.error: "Warning: unrecognized command line flag -allow-origins\n" console.error: "Warning: unrecognized command line flag -disable-dev-shm-usage\n" console.error: "Warning: unrecognized command line flag -remote-allow-hosts\n" Read port: 59507 WebDriver BiDi listening on ws://127.0.0.1:64282 [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /var/folders/8d/wg845lkj6q54nvg5hfglhbjh0000gq/T/rust_mozprofile4GVRD6/search.json.mozlz4", (void 0))) DevTools listening on ws://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Jun 02, 2023 4:39:20 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C 1685720362480 RemoteAgent INFO Perform WebSocket upgrade for incoming connection from 127.0.0.1:59534 JavaScript error: chrome://remote/content/server/WebSocketHandshake.sys.mjs, line 168: Error: The handshake request has incorrect Origin header http://127.0.0.1:64282/ Jun 02, 2023 4:39:22 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Invalid Status code=400 text=Bad Request java.io.IOException: Invalid Status code=400 text=Bad Request at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92) at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118) at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833)
Jun 02, 2023 4:39:22 PM org.openqa.selenium.support.events.EventFiringDecorator callListenerMethod WARNING: null java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.openqa.selenium.support.events.EventFiringDecorator.callListenerMethod(EventFiringDecorator.java:311) at org.openqa.selenium.support.events.EventFiringDecorator.fireAfterEvents(EventFiringDecorator.java:252) at org.openqa.selenium.support.events.EventFiringDecorator.lambda$afterCall$1(EventFiringDecorator.java:177) at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4204) at org.openqa.selenium.support.events.EventFiringDecorator.afterCall(EventFiringDecorator.java:177) at org.openqa.selenium.support.decorators.DefaultDecorated.afterCall(DefaultDecorated.java:53) at org.openqa.selenium.support.decorators.WebDriverDecorator.lambda$createProxy$0(WebDriverDecorator.java:295) at jdk.proxy2/jdk.proxy2.$Proxy43.get(Unknown Source) at net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:172) at net.serenitybdd.core.pages.PageObject.openPageAtUrl(PageObject.java:981) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:879) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:867) at xx.xxx.xx.domain.component.ui.stepLib.UiStepLib.navigateToxxxxPage(UiStepLib.java:40) at xx.xx.xx.domain.component.ui.stepLib.UiStepLib$ByteBuddy$fuDTSiIN.navigateToxxxxPage$accessor$1Lht6Qop(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:504) at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:484) at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:458) at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:210) at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:197) at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:85) at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51) at xx.xxx.xx.domain.component.ui.stepLib.UiStepLib$ByteBuddy$fuDTSiIN.navigateToxxxxPage(Unknown Source) at xx.xxx.xx.domain.component.ui.steps.StepDefinitions.iOpenGoogle(StepDefinitions.java:29) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.cucumber.java.Invoker.doInvoke(Invoker.java:66) at io.cucumber.java.Invoker.invoke(Invoker.java:24) at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47) at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29) at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66) at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63) at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10) at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92) at io.cucumber.core.runner.TestStep.run(TestStep.java:64) at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51) at io.cucumber.core.runner.TestCase.run(TestCase.java:104) at io.cucumber.core.runner.Runner.runPickle(Runner.java:73) at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110) at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117) at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123) at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:200) at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at io.cucumber.core.runtime.Runtime.run(Runtime.java:87) at net.serenitybdd.cucumber.cli.Main.run(Main.java:27) at net.serenitybdd.cucumber.cli.Main.main(Main.java:18) Caused by: org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://127.0.0.1:64282/devtools/browser/021787c4-2daa-47cc-987a-8901c8ac82dd Build info: version: '4.0.0', revision: '3a21814679' System info: host: 'MacBook-Pro.local', ip: 'xxx.xxxx.xx.xx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.3.1', java.version: '17.0.5' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.(NettyWebSocket.java:104) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:137) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:127) at org.openqa.selenium.devtools.Connection.(Connection.java:77) at org.openqa.selenium.firefox.FirefoxDriver.maybeGetDevTools(FirefoxDriver.java:359) at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:441) at com.deque.html.axecore.extensions.WebDriverExtensions.closeAboutBlank(WebDriverExtensions.java:146) at com.deque.html.axecore.selenium.AxeBuilder.analyzePost43x(AxeBuilder.java:782) at com.deque.html.axecore.selenium.AxeBuilder.analyzeRawContext(AxeBuilder.java:652) at com.deque.html.axecore.selenium.AxeBuilder.analyze(AxeBuilder.java:624) at xx.xxx.xx.xxx.accessibility.AccessibilityWrapper.checkPageForAccessibility(AccessibilityWrapper.java:73) at xx.xxx.xx.xxx.accessibility.BrowserListener.afterGet(BrowserListener.java:23) ... 68 more