2

Capybara - spec with `inside_window` does not work without` sleep`

 2 years ago
source link: https://www.codesd.com/item/capybara-spec-with-inside-window-does-not-work-without-sleep.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Capybara - spec with `inside_window` does not work without` sleep`

advertisements

I have a spec that clicks a button, which triggers some JS generating url and opens it in a new window:

new_window = window_opened_by { find('#search_postcode').click }
within_window new_window do
  expect(page.current_url).to include('postcode.nl')
end

This does not work. I get the following error:

Failure/Error: expect(page.current_url).to include('postcode.nl')
       expected "about:blank" to include "postcode.nl"

However, when I add sleep 1, the spec passes:

within_window new_window do
  sleep 1
  expect(page.current_url).to include('postcode.nl')
end

Is it possible to get this working without the sleep?


You can check for a selector within the new windows html. Capybara then should wait the default_waittime for the element to appear. Like:

within_window new_window do
  expect(page).to have_selector('.your_class_here')
  expect(page.current_url).to include('postcode.nl')
end

Related Articles

Sync problem with Jquery - does not work without warning

I have a couple of buttons that when clicked, I changed their class using Jquery. My problem is that its only works if I call an alert first. I know this must be due to something that has not been loaded yet, but I can't understand who and why. This

Logging in with MSBuild does not work with files extracted in BATCH

I have the problem that logging is not made when rebuilding a solution with checked out files. I clearly did not understand what is going wrong. So I decided to ask the community. I have two different solutions, but I want to use the check out files

Flash does not work without www

I have a flash movie which loads some images dynamically, through hphp gateway files. It works fine accessing through http://www.biaginiproperties.com/biagini-web but not through http://biaginiproperties.com/biagini-web . So it does not work without

Android paddingBottom does not work without paddingTop

I am currently using a layout that contains a RelativeLayout inside a ScrollView. I want the RelativeLayout to be contained 5dp away from the bottom of the ScrollView so it does not overlap the background I have behind it, to achieve this I was using

The website does not work without default.aspx

I have developed Telerik based web application.While testing on local host (running directly from .NET ) it works fine. but when hosted under IIS it does not work as expected. we have a default.aspx page on root , and we have added a user control(log

My project codeigniter does not work without index.php online

My Codeigniter project worked well in localhost (i am using linux Cpanel) https://localhost/project/profile But without index.php in link it does not work online https://domainname.in/index.php/profile .htaccess file RewriteEngine on RewriteCond $1 !

Codeigniter does not work without index.php in Get Requests?

I use the following .htaccess: AddDefaultCharset utf-8 RewriteEngine On RewriteBase / DirectoryIndex index.php Options All -Indexes RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L] Also set

spark-submit yarn-cluster with --jars does not work?

I am trying to submit a spark job to the CDH yarn cluster via the following commands I have tried several combinations and it all does not work... I now have all the poi jars located in both my local /root, as well as HDFS /user/root/lib, hence I hav

Jquery. Changing the width of div with animation does not work

Hello everybody i have variable(widthPercent) where i store percent for example: 67.33% when i trying to change width with jquery animation it does not works : $(this).animate({ width: widthPercent, }, 2500); }); but changing width with css working g

Xpath to locate li with text does not work

Using the xpath //ul//li[contains(text(),"outer")] to find a li in the outer ul does not work <ul> <li> <span> not unique text, </span> <span> not unique text, </span> outer ul li 1 <ul > <li> inne

Rails 3 best_in_place edit does not work without refreshing the page

I took the comments code from Bernat's blog rails mini tutorial I tried adding the edit in place functionality by using his best_in_place gem. For the most part it worked right My code is deployed at http://falling-spring-3964.herokuapp.com/comments

Application with XDK does not work

I am using org.pushandplay.cordova.apprate with XDK for Android. It just does not work. Maybe it's a syntax problem, but I cannot figure it out. I have already searched quite some forums with not sufficient answer. Here's how I did it: I installed th

Using the lein project with / lib does not work

When using lein 2.2, trying to put jar files in /lib does not work. I tried and it doesn't seems to work but plenty of docs out there says this way still works.The lib directory functionality was removed in Leiningen v2.0, in favor of a repository (r

The Python Spark Streaming example with textFileStream does not work. Why?

I use spark 1.3.1 and Python 2.7 It is my first experience with Spark Streaming. I try example of code, which reads data from file using spark streaming. This is link to example: https://github.com/apache/spark/blob/master/examples/src/main/python/st

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK