I'm new to using cucumber and ruby for doing BDD unit tests and would like to get some help regarding an error that is occurring when try to run the test without the UI.
If I have got any terms or phase incorrect, please let me know.
Scenario : On the page there is a drop down list, which pulls back data once you start typing. In the test, I enter a value and it searches for the data and once it returns I click on the selected value. This is done with the below code,
selectClient.fill_in 'client', with: client_name
page.has_no_css?('.Select-loading-zone')
selectClient.find('[name=client]').send_keys(:enter)
selectClient is a var that is used to find the section where the dropdownlist is located so that I don't search the whole page for to find the control.
This works correctly when it is running for the UI but when it is running without the UI I get the following errors, as the selected item is being clicked or selected.
Capybara::Poltergeist::MouseEventFailed: Firing a click at co-ordinates [122, 261.5] failed. Poltergeist detected another element with CSS selector 'html.no-js body.ng-scope.rebranding div.wrapper.ng-scope div.inner.ng-scope div.container-fluid div.ng-scope div#module-container.ng-scope div.myob section.ledger-upgrade div.row div.col-xs-24 div div div.form-group div.Select.create-business.Select--single.is-searchable div.Select-control span#react-select-2--value.Select-multi-value-wrapper div.Select-placeholder' at this position. It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
I have tried the suggested change by using the following
selectClient.find('[name=client]').trigger('click')
This does not seems to work for both the UI and no UI. With the UI, I get the following error message
Capybara::NotSupportedByDriverError: Capybara::Driver::Node#trigger
With no UI, the click does not get fired or selected.
I have tried the following options but still no luck as the selected is not click or selected with no UI.
selectClient.find('[name=client]', :visible=> false).trigger('click')
selectClient.find('[name=client]', :visible=> false).trigger(':enter')
selectClient.find('[name=client]', :visible=> false).trigger(':return')
selectClient.find('[name=client]', :visible=> false).send_keys : enter
selectClient.find('[name=client]', :visible=> false).native.send_keys : return
I have also tried using Javascript with the below code snippet but does not seem to click or select the when there is no UI.
page.execute_script('var keyEvent = document.createEventObject ? document.createEventObject() : document.createEvent("Events");
if(keyEvent.initEvent){ keyEvent.initEvent("keydown", true, true); }
keyEvent.keyCode = 13;
keyEvent.which = 13;
document.dispatchEvent ? document.dispatchEvent(keyEvent) : document.fireEvent("onkeydown", keyEvent);
document.getElementsByName("client")[0].dispatchEvent(keyEvent);')
I'm using poltergeist (1.12), capybara (2.6.2), selenuim-webdriver (2.50), cucumber (>2.0)
Please let me know if there is any more details required.
Thank you.