I try to implement some Automated User Test with Behat/Mink on Selenium in a Docker.
However, I received a "failed to parse value of getElementRegion" for some Element.
Do you have any clue where I should look to solve this problem ?
I try to launch this test with docker, on a Selenium's Container.
The Behat test try to access to a div inside a modal.
I can confirm that the text is visible on the screen, it's one of my previous line in the behat's file.
I wanted to try the solution describe here, however I don't have any conf.js in my project.
I try to see during the test if the id change (With a sleep juste before trying to click), however, I can manually see it.
I don't see any other solution that the one I linked before on Google.
My Script
#javascript #second
Feature: Builder Features
In Order to use the website as an Builder
I should be able to modify the roadmap
Scenario: I can do click on the modal
When I am on "/thispage"
Then I should see "The Title who open the Modal"
Then I click on ".form-check-label"
Then I wait "1"
Then I wait until "#generic-modal" load
Then I should see "The title of the modal"
Then I should see "The description of the modal"
Then I click on "#check47"
Then I press "Close the modal"
The PHP behind I click on :
/**
* #Then /^I click on "([^"]*)"$/
*/
public function iClickOn($selector)
{
$page = $this->getSession()->getPage();
$element = $page->find('css', $selector);
if (empty($element)) {
throw new Exception("No html element found for the selector ('$selector')");
}
$element->click();
}
The docker-compose's Selenium part
selenium:
image: selenium/standalone-chrome-debug:latest
networks:
app_tier:
ipv4_address: 172.11.1.4
environment:
- SCREEN_WIDTH=1920
- SCREEN_HEIGHT=1080
ports:
- "5900:5900"
volumes:
- "/dev/shm:/dev/shm"
- "../features/file:/usr/share/tag/file/"
The Behat's Extension in behat.yml
extensions:
Behat\MinkExtension:
base_url: "http://172.11.1.3"
sessions:
javascript:
selenium2:
capabilities: {"browserName": "chrome", "browser": "chrome", 'chrome': {'switches': ['--whitelisted-ips']}, "marionette": true, "extra_capabilities": {"goog:chromeOptions":{"w3c":false,"args":["start-maximized", 'disable-dev-shm-usage', 'disable-extensions']}}}
wd_host: 'http://172.11.1.4:4444/wd/hub'
Behat\Symfony2Extension: ~
I should pass all the behat's script without any error.
However, this message appears :
Then I click on "#check27" # FeatureContext::iClickOn()
unknown error: failed to parse value of getElementRegion
(Session info: chrome=77.0.3865.75)
(Driver info: chromedriver=77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865#{#442}),platform=Linux 4.19.23-coreos-r1 x86_64) (WebDriver\Exception\UnknownError)
Related
using chrome 78 and chromedriver78
When i click an audio file or try to stop an audio using selenium tests i am getting this error.
Error:
org.openqa.selenium.JavascriptException: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.
Note it happens only with remote webdriver and its not consistent.
Error stack trace:
When the audio player of the "item_1" element is stopped in "[data-rcfid='checkbox_7']"
org.openqa.selenium.JavascriptException: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.
(Session info: chrome=78.0.3904.70)
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'ip-10-0-10-137', ip: '10.0.10.137', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-71-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 78.0.3904.70, chrome: {chromedriverVersion: 78.0.3904.70 (edb9c9f3de024..., userDataDir: C:\Windows\proxy\scoped_dir...}, goog:chromeOptions: {debuggerAddress: localhost:1674}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: accept, webdriver.remote.sessionid: eb7d4195af3426c181317a16028...}
Session ID: eb7d4195af3426c181317a160286b15e0125b619
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:611)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:638)
at webDriver.Driver.click(Driver.java:147)
at pageObjects.ActivityPageObject.clickAudioInlineStopIn(ActivityPageObject.java:205)
at stepDefinition.Activity.theAudioPlayerOfTheElementIsStoppedIn(Activity.java:61)
at ✽.When the audio player of the "item_1" element is stopped in "[data-rcfid='checkbox_7']"(/opt/atlassian/bamboo-home/xml-data/build-dir/16744451/RCF1-RMIT-BROW3/rcf-automation-tests/src/test/resources/featureFiles/interactions/markedInteractions/CheckBox.feature:433)
I had same issue and observation was , multiple elements by same xpath. Finding different unique xpath resolved it
I have faced the same issue and was able to resolve it by simply scrolling the window down to the element I am targeting. Seems like the element wasn't showing in the viewport and that's why it wasn't visible to selenium.
Try to add the following lines before finding and clicking the element:
driver.execute_script("window.scrollTo(0, window.scrollY + 100)")
driver.implicitly_wait(3)
I experienced this same issue while trying to click a cell in an AngularJS grid. I confirmed that my XPath query resulted in only one result, and then explored if adding in a Wait Condition would help. As it turned out, adding in a Wait here allowed the code to continue without error.
The below code is the method I used to click the cell. I switched from Click() to an Action as the Click() method was being intercepted by a different element.
public void ClickEmploymentChangeLogButton()
{
Wait.Until(WaitConditions.ElementIsVisibleAndEnabled(EmploymentChangeLogButton));
Actions actions = new Actions(driver);
actions.MoveToElement(EmploymentChangeLogButton).Perform();
actions.MoveToElement(EmploymentChangeLogButton).Click().Perform();
}
WaitConditions is a separate class to model some of the behaviour of the deprecated ExpectedConditions package.
Here's the method inside WaitConditions that is used above.
public static Func<IWebDriver, bool> ElementIsVisibleAndEnabled(IWebElement element)
{
return (driver) =>
{
try
{
return element.Displayed && element.Enabled;
}
catch (Exception)
{
// If element is null, stale or if it cannot be located
return false;
}
};
}
The problem is, that you've found an element that is not graphically displayed in the web browser - location property has value: X=0 and Y=0; so you've probably located a wrong element.
This error message...
Javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite
...implies that the WebDriver instance was unable to find the desired element using the Locator Strategy for one or the other reasons:
The locator strategy doesn't identifies the desired element uniquely within the DOM Tree.
The element haven't loaded properly when you tried to interact with it.
Element is within an <iframe> / <frame>
The style attribute of the element contains display: none;
Element is within an shadow DOM.
Analysis
The relevant HTML would have been helpful to analyze the issue in a better way. However, you need to take care of a couple of things as follows:
Ensure that the locator strategy identifies the desired element uniquely within the HTML DOM.
Induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:
cssSelector:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("elementCssSelector"))).click();
xpath:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("elementXpath"))).click();
If the WebElement is within an <iframe> / <frame> you need to induce WebDriverWait for the desired frameToBeAvailableAndSwitchToIt().
You can find a relevant detailed discussion in Is it possible to switch to an element in a frame without using driver.switchTo().frame(“frameName”) in Selenium Webdriver Java?
References
You can find a couple of relevant detailed discussions in:
javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite
I have also faced the same issue. In my case the problem was that the element I tried to move to wasn't visible yet in the browser.
So I used time.sleep(1)
After that it worked.
This error appeared when I upgraded to ChromeDriver 88 from a version in the 70s (71?). It was actually caused by a workaround from that earlier version. This was using a dropdown in angular. Instead of clicking on an element I had to move to the element and then click on it in separate steps. When I removed the moveToElement steps the error went away
previous code
masterPage.MasterDropDown.click();
Thread.sleep(3000);
actions.moveToElement(masterPage.MasterDropDown).perform();
Thread.sleep(1000);
actions.moveToElement(masterPage.DropdownButton1).perform();
Thread.sleep(1000);
masterPage.DropdownButton1.click();
Was changed to
masterPage.MasterDropDown.click();
masterPage.DropdownButton1.click();
The error went away and it is cleaner.
Protractor creates a brand new Chrome profile every time it runs. So what i want to do it will enable popup for chrome browser every time when protractor test runs.
I don't want to use existing profile.Is there any way to do ?
You can create instance of chrome custom profile and it can be passed to capabilities.
export const chromeProfile = {
browserName : 'chrome',
maxInstances: 1,
chromeOptions: {
args: [
// mention list of all setting for chrome browser
//For example following two lines disable chrome popup
'disable-infobars=true',
'--disable-popup-blocking'
],
prefs: {
// disable password popup
'credentials_enable_service': false
}
}
};
I am trying to write code to check download is completed by selenium and chrome driver. My idea is
1.Go to download page("chrome://downloads/")
2.Check the url to ensure we have downloaded file from that site (locate http://xxxxxxxx)
3.Check download status( If I found "show in folder", it implies download success. if not, download failed)
I am stucking in step2, when I try to locate the url. I used developer tools, move cursor to the url to locate the element,and then I right click and copy the xpath. The xpath is like this
//*[#id="file-link"]
And then I try to click ctrl+F in developer tool and paste the xpath again. I cannot locate the element. Why? Checked there is no frame.
It shadow DOM and need to select /deep/ using CSS selector
downloads-manager/deep/downloads-item/deep/a[id="file-link"]
Another way of doing this could be writing a small Java utility for the same using File Class.
Something like this:
File f = new File("C:\\Users\\username\\Downloads\\Users_" + fielName+ ".xls");
Assert.assertTrue(f.exists());
This work for me on python:
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
# disable file preview
options = webdriver.ChromeOptions()
options.add_experimental_option(
'prefs', {
'profile.default_content_settings.popups': 0,
'download.default_directory': '/some/download/dir',
'download.prompt_for_download': False,
'download.directory_upgrade': True,
'plugins.always_open_pdf_externally': True,
'plugins.plugins_disabled': 'Chrome PDF Viewer',
'disable-popup-blocking': True
}
)
driver = webdriver.Chrome(options=options)
# start load file
driver.get('url-to-file')
def condition_load_file(dr: webdriver.Chrome):
return dr.execute_script("""
try {
var el = document.querySelector("body > downloads-manager").shadowRoot.querySelector("#frb0").shadowRoot.querySelector("#show");
return el !== null;
} catch(exc) {
return false;
}
""")
# open new window and go to chrome://downloads/
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[1])
driver.get('chrome://downloads/')
# waiting for download to finish
WebDriverWait(driver, 120).until(condition_load_file)
I wrote test using TestNG and selenium.
code...
actions.sendKeys(Keys.chord(Keys.CONTROL, "a"));
actions.sendKeys(Keys.BACK_SPACE);
actions.build().perform();
code...
I wanted to delete text in login window using these sendKeys, with DataProvider
#DataProvider(name = "inputs")
public Object[][] getData() {
return new Object[][]{
{"000000000", true},
{"000000000", true}
};
}
Html:
<div><input type="tel" class="valid TextInput-kJdagG iVdKHC" name="recoveryPhone" id="eb69ff0b-3427-6986-7556-b7af40ffb156" aria-describedby="eb69ff0b-3427-6986-7556-b7af40ffb156" value="+48 "></div>
Error message:
Unable to read VR
Path1523545392670 Marionette INFO Enabled via --marionette
1523545393744 Marionette INFO Listening on port 52644
1523545394180 Marionette WARN TLS certificate errors will be ignored for this session
Test work as I expected on Chrome, but on firefox these sendKeys not always mark the text, and clear this text. In project I have to use action class. Why the test runs differently?
Check this post https://github.com/mozilla/geckodriver/issues/665 against your versions (browser, browser driver, selenium etc which are always sensible to include in any question), it could be a known bug with the geckodriver.
The post includes a work around of creating the chord in a different way, using:
List<CharSequence> keyWithModifiers = new ArrayList<CharSequence>();
keyWithModifiers.add(Keys.CONTROL);
keyWithModifiers.add("a");
String ctrlA = Keys.chord(keyWithModifiers);
textFieldElem.sendKeys(ctrlA);
This approach worked for me using Selenium 3.7.1 Java bindings, gecko driver 0.18.0 (64 bit) and Firefox 57.0.2 - 59.0
It is always suggested to set the firefox profile in DesiredCapabilities and pass that through the wire ,where the hub is running . Like below
DesiredCapabilities caps = DesiredCapabilities.firefox();
FirefoxProfile profile=new FirefoxProfile(new File("Local Path to firefox profile folder"));
caps.setCapability(FirefoxDriver.PROFILE, profile);
URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver= new RemoteWebDriver(url,caps );
But sending the huge 87-90 mb profile info to hub over http ,for each selenium test case slowing down the test case execution .
I have tried configuring the grid node with "Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"", property in json node config file like below.
{
"configuration":
{
.//Other Settings
.//Other Settings
.//Other Settings
"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
"maxSession":7,
"registerCycle":5000,
"register":true
},
"capabilities":
[
{"browserName":"firefox",
"seleniumProtocol":"WebDriver",
"maxInstances":5,
"platform":"VISTA"
}
]
}
But running with the above configuration is throwing below error .
WebDriverException: Firefox profile 'E:\Firefox_Profile_Location'
named in system property 'webdriver.firefox.profile' not found
Advanced thanks for any help on how to configure the firefox profile from the node side .
You need to provide the profile in the capabilities object as a base64 encoded zip:
var fs = require('fs');
capabilities: [
{
browserName: 'firefox',
seleniumProtocol: 'WebDriver',
maxInstances: 5,
platform: 'VISTA',
firefox_profile: new Buffer(fs.readFileSync("./profile.zip")).toString('base64')
}
]
Moreover Firefox creates the missing files for a given profile. So you should keep just the necessary files in the profile depending on your needs:
Preferences: user.js
Passwords: key3.db
logins.json
Cookies: cookies.sqlite
Certificate: cert8.sqlite
Extensions: extensions/
I think you'll have to use firefox profile name and not the location.
"webdriver.firefox.profile":"default"
Have a look at this and this and this
If you want know how to create a profile follow this and this