Skip to main content

Posts

Showing posts with the label chrome

Using ChromeOptions for Capybara: Disable Images and More

Chromedriver lets us set preferences via capabilities when it is initiated by Webdriver. These preferences can be used for specific purposes for example disabling images can reduce network needs and fasten the test runs; and disabling popups can make your cases more stable by reducing non-deterministic cases. In this post I want to explain how to use these feature of Chromedriver for Capybara with Ruby, you can also apply the same method for other languages with their bindings. Sometimes bandwidth is crucial if you have parallel pipelines for test runs. Think that you have 10 parallel pipes and very pipeline consume bandwidth to complete its tasks, the most heavy part of website generally images. If we disable the images we can fasten the overall test runs. To disable the images you should set the images option to 2 in preferences. For Capybara you can disable the images by following Chrome instance: Sometimes you need to disable popups which intermittently occurs and make

Create an Alias for Interactive Console Work: Selenium and Capybara

If you are working on shell most of the time Aliases are very helpfull and time saving. For testing purposes you can use Alias for getting ready your test suites. In this post, I want to explain both running Selenium and Capybara on console and creating aliases for each.  This post is for Windows machines, if you are using Unix-like see   this post . Creating Scripts for Selenium and Capybara First of all, it is assumed that you have installed Selenium and Capybara correctly and they work on your machines. If you haven't installed, you can see my previous posts. I am using the Selenium with Python and the Capybara with Ruby. You can use several different language for Selenium but Capybara works only with Ruby.  Create scripts in a directory called scripts (in your home folder, like as  ~/scripts ) for your automation tool as following, save them as capybara.rb, sel.py :  Creating Aliases Depends on your favourite shell, you need to add the alias to .bashrc bash

An Error for Selenium - Chrome vs Firefox: stale element reference

I faced an selenium error like " stale element reference " when I changed Capybara's driver to Chrome which was not occurred in webkit and firefox. This error occurs when referencing an element which is not in DOM. Chrome gives this but it doesn't appear when I use Firefox because the dynamic object is appear after the Javascript execution finishes which means that Chrome doesn't wait until javascript execution ends .  You can escape this error by checking your scenario if there is an element requiring in the DOM which is destructed by an action in the scenario or if you have loop and the DOM is updating for each iteration the object you look for changes. However in  my case, scenario is passing with FF but not Chrome which because the Chrome is passing the next step as soon as Javascript execution starts.  I just call waiting function and then assign the variable. Finally scenario is passing for both browsers.        stale element reference: element is

Running Capybara Under Chrome, Poltergeist or Firefox

As a default Capybara runs under Firefox but if you want to change your driver you have to change your javascript driver to your new driver. But you also must define your driver as registered Capybara driver. For example if you want to run with Chrome and change your driver to chrome but not define it, it gives some errors like following irb(main):007:0> visit "http://www.amazon.com" Capybara::DriverNotFoundError: no driver called :chrome was found, available drivers: :rack_test, :selenium, :poltergeist from /Library/Ruby/Gems/2.0.0/gems/capybara-2.4.1/lib/capybara/session.rb:77:in `driver' from /Library/Ruby/Gems/2.0.0/gems/capybara-2.4.1/lib/capybara/session.rb:226:in `visit' from /Library/Ruby/Gems/2.0.0/gems/capybara-2.4.1/lib/capybara/dsl.rb:51:in `block (2 levels) in ' if you add the following line into your env.rb module, you will successfully run under Chrome driver. Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver

Selenium Chromedriver Error Message: u'unknown error: unable to discover open pages

If you use selenium webdriver to automate regression test cases, you may have got the following error. Because a bug in chromedriver version 2.3 causes this error. According to Google Dev ., this problem had fixed in version 2.6.  Assigning the chrome driver to driver leads to this error by the line 38, which is self.driver = webdriver.Chrome() . To solve the problem, you need to change the chromedriver version 2.3 in your execution path, like C:\Windows\System32 under Windows, with newer version. You can download chrome driver from googleapis .   Error message may like this: Traceback (most recent call last):   File "D:\workspace\automation_project\run.py", line 32, in <module>     m = Project(browser, server)   File "D:\workspace\automation_project\test_case_imps.py", line 38, in __init__     self.driver = webdriver.Chrome()   File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line

Selenium Error "Element is not currently interactable and may not be manipulated"

Selenium webdriver can drive different browsers like as Firefox, Chrome or Internet Explorer. These browsers actually cover the majority of internet users, so testing these browsers possibly covers the 90% of the internet users. However, there is no guaranty that the same automation scripts can work without a failure on these three browsers. For this reason, automation code should be error-prone for the browsers you want to cover. The following error is caught when the test script run for Chrome and Internet Explorer, but surprisingly there is no error for the Firefox. Selenium gives an error like below: Traceback (most recent call last):   File "D:\workspace\sample_project\sample_run.py", line 10, in <module>     m.login()   File "D:\workspace\ sample_project \test_case_imps.py", line 335, in login     driver.find_element_by_id("id_username").clear()   File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\r

Internet Explorer Launching Gives Errors in Selenium Webdriver

As selenium user know, Selenium script can be run via FireFox, Chrome and Internet Explorer if you set up the environments correctly, you may read this post if you are un-sure. If you face an error while launching Internet explorer in selenium test automation, you need to set all the security zone in the same mode (enabled, or disabled mode). If you change security zone, selenium gives the following errors, and the last one says " Protected Mode settings are not the same for all zones " so you can set the protected mode by Tool > Internet Options > Security Tab then set Internet, Local Internet, Trusted Sites, and Restricted Sites as same mode, enabled or disabled. Then click "Apply" and "OK" and repeat your tests. File "C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\webdriver\ie\webdriver.py", line 53, in __init__     desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)   File "C:\Python27\lib\site-packa

Using Selenium Webdriver via Internet Explorer (ie) and Chrome

As it is known Selenium IDE is an extention for Firefox browser. And the Webdriver is an application to send commands to firefox to drive it. As a default set-up, firefox comes with it for running automated test cases. However, sometimes running compatibiliy related test cases via, especially, Internet Explorer but Chrome may be needed. If you want to run your test cases via other browsers you need to do some configuration changes in your test environment. Download the webdriver of browsers for selenium web site: For Internet Explorer click here and dowload  IEDriverServer 32bit or 64bit depending on your system For Google Chrome, dowload Chronium webdriver click here   and dowload chromedriver_win Put the webdrivers to your path wich your executable files are present. It is generally like this C:\Windows\System32    You need to allow IE Driver and Chrome Driver to access your network: Allow Access to IE Driver and Chrome Driver Finally call the drivers you want to use