Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99410

Rails Capybara not detecting vivsiblity of flex item

$
0
0

I am doing display: flex an element on button click and then display: none to the same element after some ajax calls. I am doing the integration testing for the same using Capybara with Selenium driver. The problem is that capybara detects the visibility of the element and sometimes it does not even though the element is visible. I have tried giving different wait values but still it works sometimes and sometimes it does not. Is there anyway I can rectify this? The code is as below:

ele.addEventListener('change', () => {
  showSpinner(true);
  ajaxCall().then(() => showSpinner(false));
}

showSpinner = (flag) => {
  let spinner = document.getElementById('spinner');
  if (!spinner) {
    return;
  } else if (flag) {
    spinner.classList.add('show');
  } else {
    spinner.classList.remove('show');
  }
};

.spinner.show {
  display: flex;
}

.spinner {
  display: none;
  // other properties
}

In test file

choose 'radio_button' // if radio button
select 'some text', from: 'dropdown_element' // if dropdown
assert page.has_css?('.spinner', wait: 0)

This works sometimes and sometimes it does not. The element is selected or clicked. That works. But not has_css. Also I tried using assert_css but I am getting error. So how can I write the testcase for the above problem?


Viewing all articles
Browse latest Browse all 99410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>