Selenium IDE tests failing when run on Selenium Grid - selenium

I have a setup where I make simple tests with the Selenium IDE, then save the project as a *.side file to a repository, which a server running Selenium Grid then pulls, runs all tests contained and then emails me the results. For most of the tests I get the same results as locally, only a few cookie banners caused trouble because it seems that locally it's not an issue if you don't click them away but when the tests run on the Selenium Grid they will fail because the cookie banner blocks all clicks. Now I have a similar issue but there is nothing like a cookie banner. I am testing a Swagger UI and whenever I run the test on Selenium Grid I get failures like this:
FAIL DefaultSuite/click-a-couple-headers.test.js (7.275s)
✕ click-a-couple-headers (5319ms)
● click-a-couple-headers
ElementClickInterceptedError: element click intercepted: Element <div class="opblock-summary opblock-summary-get">...</div> is not clickable at point (476, 18). Other element would receive the click: <header>...</header>
(Session info: chrome=80.0.3987.106)
at Object.throwDecodedError (../../../node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/error.js:550:15)
at parseHttpResponse (../../../node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:560:13)
at Executor.execute (../../../node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:486:26)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 7.58s, estimated 8s
Searching for the CSS selector in the Selenium IDE test this seems to be the part where it fails:
{
"id": "12345678-1111-5555-8888-1234567890ab",
"comment": "",
"command": "setWindowSize",
"target": "968x648",
"targets": [],
"value": ""
}, {
"id": "12345678-2222-6666-8888-1234567890ab",
"comment": "",
"command": "runScript",
"target": "window.scrollTo(0,413)",
"targets": [],
"value": ""
}, {
"id": "12345678-4444-7777-8888-1234567890ab",
"comment": "",
"command": "click",
"target": "css=#operations-category-method_path_to_endpoint > .opblock-summary",
"targets": [
["css=#operations-category-method_path_to_endpoint > .opblock-summary", "css:finder"],
["xpath=//div[#id='operations-category-method_path_to_endpoint']/div", "xpath:idRelative"],
["xpath=//span[2]/div/div/span/div/div", "xpath:position"]
],
"value": ""
}
So I thought it might be a timing issue with the scrolling operation, so I added a whatForElementVisible command before all clicks:
/* scroll command */
{
"id": "12345678-3333-7777-8888-1234567890ab",
"comment": "",
"command": "waitForElementVisible",
"target": "css=#operations-category-method_path_to_endpoint > .opblock-summary",
"targets": [
["css=#operations-category-method_path_to_endpoint > .opblock-summary", "css:finder"],
["xpath=//div[#id='operations-category-method_path_to_endpoint']/div", "xpath:idRelative"],
["xpath=//span[2]/div/div/span/div/div", "xpath:position"]
],
"value": "30000"
},
/* click command */
Locally the test still worked fine in Firefox and Chrome (which the Grid runs) but on the Grid it fails with the same error as before. Does someone know how to fix this issue or how to properly debug it?

Turns out it wasn't an issue with timing at all, but rather a problem with an information bar (about the browser being controlled with automation software) at the top of the browser window that I didn't get locally. The video recording feature of Selenium Grid Extras proved to be really useful to track this down. Useful to know because the README of the repo doesn't mention it: the node info (and videos) are exposed on the ports 3100 (Chrome browser) and 3200 (FireFox browser) respectively.

Related

How to debug react-native-web with Expo and vscode?

I am trying to find how react-native-web apps (specifically using Expo and vscode) can be debugged.
I found guidance neither in the web, nor in the react-native-web's own site.
The debug configuration that comes with the React Native Tools aims to run within the Expo application, but my intention is to use the browser to debug/test the react-native-web behaviour.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug in Exponent",
"request": "launch",
"type": "reactnative",
"cwd": "${workspaceFolder}",
"platform": "exponent",
"expoHostType": "local"
}
]
}
I could have found the method. For all who are stuck the method is as follows.
Go to the debug pane.
If previously not chosen choose "Run and Debug"
Choose add configuration.
Choose Chrome: Launch (we would like to launch a chrome browser when we start debugging, you may have alternative browsers, or you may choose to have the attach approach also). (We will come back to here after step 5.)
It will add a configuration like:
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "http://localhost:8080", // This line should be modified at step 6
"webRoot": "${workspaceFolder}"
},
Open the vscode's terminal and run expo start --web and you should see your server and related port. (Below, in my case it is port 19006.)
Modify the configuration.
{
"name": "Launch Chrome 19006", // Modified as 19006
"request": "launch",
"type": "chrome",
"url": "http://localhost:19006", // Modified as 19006
"webRoot": "${workspaceFolder}"
},
Confirm that expo start --web is running then go to the debug pane and launch a browser by the debug start button, with "Launch Chrome 19006" value:
After these 6 steps you should be able to debug Expo applications that use react-native-web through the vscode.

Selenium IDE doesn't do anything for "pause" command

I'm using the selenium IDE for Chrome on Mac Big Sur. I want to add a puse in between commands to see why something isn't executing properly. This is in my ".side" file
}, {
"id": "32f35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "pause",
"target": "",
"targets": [],
"value": "100000"
}, {
I have put a really high value but when I play back my test, it just breezes through it without pausing at all, although it tells me the command was successfully run
What's the right way to pause my test?
Use Target instead of Value, Like below
Target: 100000
instead of
value: 100000
Also,
Set speed to fastest (Actions --> Fastest), otherwise it won't work.

FluentWait not ignoring exceptions [duplicate]

This question already has answers here:
NoSuchElementException, Selenium unable to locate element
(3 answers)
The type FluentWait is not generic; it cannot be parameterized with arguments <WebDriver> error for FluentWait Class through Selenium and Java
(6 answers)
Closed 3 years ago.
I have some Selenium Chromedriver code that is clicking on a button, then several seconds later an item appears on the web page that I need to capture the text (basically a success/fail response). I can see the button click is working, but the script stops with an exception almost immediately after the button is pressed. I can verify the button click has worked because a few seconds after the script has stopped, the element to be checked appears on screen.
The exception is;
Caused by org.openqa.selenium.NoSuchElementException: no such element
This makes sense because at the time this exception occurs the element is not there, and it won't be there for several seconds.
The exception comes from this command;
myWaitVar.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[#data-aura-class=\"forceActionsText\"]")));
With myWaitVar defined as;
myWaitVar = new FluentWait<WebDriver>(driver)
.withTimeout(Duration.ofSeconds(120))
.pollingEvery(Duration.ofSeconds(10))
.ignoring(org.openqa.selenium.NoSuchElementException.class);
The ignoring command was changed from NoSuchElementException.class because I saw another Stackoverflow response saying that it has to be the org.openqa.selenium version.
From what I understand, the line should wait for up to 120 seconds, checking every 10 seconds for the element to appear. However, the test result shows that it completes in 0.076 seconds.
I would be happy if I had got the xpath wrong and it actually took 120 seconds to break. But with it breaking in just over a second I believe the issue could be somewhere else.
Edit: The element is identified correctly if I add a thread sleep of exactly 7 seconds. With a 7 second delay, the element appears on screen, the fluentwait passes and so does the rest of the test. This suggests that the element locator is accurate, there is no iframe to navigate, no other DOM setting that prevents the locator from working at the right time. I have also tried 'presence of' as well as 'visibility of' with the same result (I can't try 'is clickable' as it's just a text field and not clickable).
Edit 2: This is the debugging response for this request.
[1567065113.459][INFO]: [ebbf7271cafbc1f7e2dba437ac32b004] COMMAND FindElement {
"using": "xpath",
"value": "//*[#data-aura-class=\"forceActionsText\"]"
}
[1567065113.459][INFO]: Waiting for pending navigations...
[1567065113.459][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=246) CB6F87B5FC515B000A21C08C843E210B {
"expression": "1"
}
[1567065113.464][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=246) CB6F87B5FC515B000A21C08C843E210B {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[1567065113.464][INFO]: Done waiting for pending navigations. Status: ok
[1567065113.467][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=247) CB6F87B5FC515B000A21C08C843E210B {
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[1567065113.481][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=247) CB6F87B5FC515B000A21C08C843E210B {
"result": {
"type": "object",
"value": {
"status": 0,
"value": null
}
}
}
[1567065113.481][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=248) CB6F87B5FC515B000A21C08C843E210B {
"expression": "1"
}
[1567065113.483][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=248) CB6F87B5FC515B000A21C08C843E210B {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[1567065113.483][INFO]: Waiting for pending navigations...
[1567065113.483][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=249) CB6F87B5FC515B000A21C08C843E210B {
"expression": "1"
}
[1567065113.483][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=249) CB6F87B5FC515B000A21C08C843E210B {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[1567065113.483][INFO]: Done waiting for pending navigations. Status: ok
[1567065113.483][INFO]: [ebbf7271cafbc1f7e2dba437ac32b004] RESPONSE FindElement ERROR no such element: Unable to locate element: {"method":"xpath","selector":"//*[#data-aura-class="forceActionsText"]"}
(Session info: chrome=76.0.3809.132)

Unable to connect to a site from Testcafe IDE on OSX

My fixtures are set up like so
{
"fixtures": [
{
"name": "login",
"pageUrl": "http:\/\/localhost:3000\/",
"tests": [
{
"name": "type name",
"commands": [
{
"type": "type-text",
"studio": {
},
"callsite": "0",
"selector": {
"type": "js-expr",
"value": "input[type=email]"
},
"options": {
},
"text": "example#email.com"
}
]
}
]
}
]
}
with one simple test to find the input and type some text but when running the command I get
testcafe chrome login.testcafe
ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
Type "testcafe -h" for help.
I've seen this issue a couple of times on their issues board one relating to CI integration on a Linux server and another which seems like a similar issue of trying to connect to localhost
https://github.com/DevExpress/testcafe-browser-provider-electron/issues/20
https://github.com/DevExpress/testcafe/issues/1133
New to testcafe any help would be appreciated!
I've found the solution some network policies don't allow access to your machine on some ports in my example it's 57501.
testcafe chrome login.testcafe --hostname localhost
adding --hostname resolves the issue
documentation
https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#--hostname-name
I still don't know how to launch from the IDE but this resolves my main issue.
TestCafe Studio Preview does not support setting command line options (hostname in your case). The TestCafe team is going to implement this functionality in the official release.
So, for now, it is only possible to run tests via a command line.
UPDATE:
You can set the hostname option in the TestCafe Studio Settings dialog:

Taking screenshots with Selenium Builder

Using Selenium Builder, I've created the following json file:
{
"type": "script",
"seleniumVersion": "2",
"formatVersion": 2,
"steps": [
{
"type": "get",
"url": "http://stackoverflow.com/"
},
{
"type": "saveScreenshot",
"file": foo.png"
}
],
"data": {
"configs": {},
"source": "none"
},
"inputs": [],
"timeoutSeconds": 60
}
I tried running it on Windows 7 and two different Ubuntu machines. Instead of the filepath "foo.png" I had also inserted "E:\foo.png" / "/home/swege/foo.png". However, I always get the "exception":
Could not take screenshot of current page - [object Object]
At least I would like to be able to read the "error object", but every system just puts out that the error is a JavaScript object. Any idea how to fix the issue or read the full error message?
Try following :
http://www.ontestautomation.com/how-to-create-screenshots-in-your-selenium-webdriver-tests/
Above can help you to get exact code that how you can take screenshots using selenium.
So I pulled down and looked at the source for Selenium Builder 2 and found two files that I think show the origin of the error, command_processor.js and driver_component.js.
I can't make out why the error is occurring - maybe someone here can build on this?
Try using a full file path, not just foo.png. On Mac, these worked for me: ~/foo.png and ~/Downloads/screenshots/foo.png.
It's also important that the folder exists and is writable by the account running the web browser.