Hot answers tagged

9

This might be useful. driver.findElement(By.tagName("body")).sendKeys("Keys.ESCAPE"); OR JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("return window.stop");


7

have_content actually takes a regexp as parameter. You can use the i flag to make the search case insensitive expect(page).to have_content(/my case insensitive search/i)


6

If you are using zsh shell: repeat 10 { command } On basic shell: for _ in {1..10} do command; done If you can run the tests in parallel, you can use the GNU Parallel: parallel command ::: {1..1000} Tutorial videos: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 Text tutorial: http://www.gnu.org/software/parallel/parallel_tutorial.html Your ...


6

$driver.find_element(:xpath,element2) Above, you are trying to find an element. .displayed? Now you are trying to check the state in a element. The exception is thrown by the first computation; the displayed? is never executed. Given that, in order to avoid code duplication and different behaviors in different parts of the suite, I'd recommend to you ...


5

As @Niels van Reijmersdal mentioned, it makes sense to use the language in which you have local experts available. But you don't have to use the same language - use the language in which your team will be more productive. Python and Ruby are almost identical in expression power. I would argue that Python is more readable, which is significant advantage when ...


5

If you are using firefox then you can set preference for default timeout: fp = webdriver.FirefoxProfile() fp.set_preference("http.response.timeout", 5) fp.set_preference("dom.max_script_run_time", 5) driver = webdriver.Firefox(firefox_profile=fp) driver.get("http://www.google.com/") This will stop page load after 5 seconds.


4

If you want to simulate the browser's STOP button, this post should help you out https://stackoverflow.com/questions/5453423/how-to-stop-the-page-loading-in-firefox-programaticaly


3

In my opinion it's better to develop with the tools and languages that you love. Here are good Selenium recipes, code examples & API references for Ruby: http://samples.leanpub.com/selenium_recipes-sample.pdf https://code.google.com/p/selenium/wiki/RubyBindings http://rubydoc.info/gems/selenium-webdriver/2.2.0/ (the right top corner)


3

I was able to determine what was causing the issue. After new session initialization: session = Capybara::Session.new(driver) I was calling following method to maximise the browser window: session.driver.browser.manage.window.maximize Looks like sometimes a new browser window is opening too slow and when Capybara tries to maximise the window, this ...


3

You could use next algorithm Get all links from page. Implement ruby script to check all links First steps are implemented in two ways Open page by webdriver, and get all links by tag , for example Get page by http request and parse html code by regex Second step: Implement script for request sending Use this link for implemention script. Good luck!


3

You can use the global hook at_exit: at_exit do your script goes here end For example, in features\support\env.rb I typically have: at_exit do browser.close end


3

There were a few possible solutions to this over on Stackoverflow on Stop browser load from selenium webdriver. This included: Installing an extension in Chrome called Stop load using the built in pageLoadTimeout() method in Selenium using Sikuli or Autoit to access the browser's native controls


3

Have you seen these? I did a search in google for: "rest testing with ruby" How to test a JSON REST API REST API test cucumber steps best practise On the other hand, if you have Ruby skills, then you can write your own library to deal with REST responses or you can use something from RubyGems.


3

You are checking that an element that doesn't exist is displayed. Elements must exist if they are displayed so you are failing before you get to the .display? For the findElement part, you need to add a rescue and from there you could rescue the error and provide a useful message: rescue Selenium::WebDriver::Error::NoSuchElementError raise Selenium::...


3

Watir is Object Oriented while capybara is domain specific. Capybara is simple to use, quick to deploy but maintenance will be an issue over time. Watir needs overhead to develop its page abstraction and etc but it pays for its dividend in the future for its maintainability.


3

No The highest version of Safari for Windows is too old. It's also not able to handle many modern web technologies, so you're better off using either a containerized version of Safari, or sticking to Mac OS to test Safari.


2

I was facing a similar issue, and found a solution in this article: http://swdandruby.wordpress.com/2013/05/11/headless-gem-causes-errnoeconnrefused/ You have to specify a different display number for each browser headless instances you need. So if you want to run at the same time chrome and firefox in separate headless mode, you can do something like: ...


2

find_elements(:name,"Like")[0].click find_elements(:name,"Like")[1].click ... button(1).click button(2).click ... ele_index(:UIAButton,1).click ele_index(:UIAButton,2).click ... buttons[0].click buttons[1].click ...


2

It may be easier to just openAndWait() the URL and do some conditional logic to see if the page displays a maintenance message or not. Incorporating a proxy (as mentioned in other responses) for this one use case sounds like a rather expensive operation. In the past I have setup a proxy to ensure that a tracking pixel (Google Analytics or Omniture, for ...


2

Create a script in your home directory, e.g. $ cat run_spec_100_times.sh cd ~/eq/lynx for i in `seq 1 100`; do rspec spec/features/survey_spec.rb done cd ~ Modify the script to be executable with chmod +x run_spec_100_times.sh The use it with . run_spec_100_times.sh


2

Selenium 3.0 is a drop-in replacement, so it's as simple as updating your Gemfile to use the latest version of Selenium-WebDriver (and any other libraries you want). Then run your package manager to update / install those libraries. For example, when I did this two weeks ago I ran bundle update (I use bundler). I deleted the Gemfile.lock prior to updating, ...


2

Intermittent failures are hard to fix due to their very nature - they don't always happen. So when you think you have fixed them you often can't be sure just by 'running the spec'. You usually need to run the spec many times to have a sense for whether a 'fix' has worked. This makes addressing them hard. It requires a variety of techniques and approaches ...


2

It's possible to force this status with a Javascript injection via execute_script. To simulate a visible document: Object.defineProperty(document, 'visibilityState', {value: 'visible', writable: true}); Object.defineProperty(document, 'hidden', {value: false, writable: true}); document.dispatchEvent(new Event("visibilitychange")); To simulate an hidden ...


2

POM can be useful to avoid unnecessary refactoring. For your development stack I would suggest installing the site_prism gem - it allows you to easily create and compose page objects. In this Pull Request you can see examples that I wrote, showing how the aforementioned gem separates clearly the page object components, its functions and how to use them with ...


2

Step 0. Set up Webdriver. require 'rubygems' require 'selenium-webdriver' driver = Selenium::WebDriver.for :chrome Step 1. Set a variable for finding values found_values= false Step 2. Get an array of all the input elements inputs= driver.find_elements('input') # all('input') if using Capybara btw Step 3. Iterate through them, e.g. inputs....


2

Minitest and Rspec are very similar. You are likely to miss the Rspec matchers, however there is an Rspec matchers gem for minitest. If you use it, there is a good chance your test will 'just work'. Minitest integration rspec-expectations is a stand-alone gem that can be used without the rest of RSpec. If you like minitest as your test runner, but prefer ...


2

If it's the system right click menu then you can't. If it's a page generated right click menu then you just interact like any other element on the page.


2

I'm not the most experienced guy when it comes to interviews, but this is my opinion on the subject. I like to separate personal interviews and assignments. Personal Interviews For me personal interviews are mainly about two things: Attitude Discovering problem solving capabilities The first one is quite obvious. Is the person a good fit to the team? Is ...


2

I've generally seen it referred to as "xSpec"; that style was popularised, if not invented, by RSpec and there are others like JSpec (for Java, which uses it but not describe). The JavaScript framework Mocha (and other tools that have adopted it, like Cypress) refers to this API as "the BDD interface". Jasmine, which also uses that style but doesn't ...


1

Think about the three steps for every test setup execute teardown Ideally this is done for every test and the database strategy used between tests is truncation. Frequently this is deemed not possible and seed data is used which would slow down the tests too much if deleted each time. In those cases each test should use the database strategy of rolling ...


Only top voted, non community-wiki answers of a minimum length are eligible