Set selenium speed doesn't work in robot framework - performance

I just login into a website, i guess it was too fast so i put "set selenium speed" under "maximize browser window" but it does not work. what happen?
here's my code.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
LoginTest
open browser https://www.demoblaze.com/index.html Chrome
set selenium speed 3seconds
maximize browser window
click element id:login2
wait until element is visible id:loginusername
input text id:loginusername etane.gapuro#gmail.com

Check indentation or a format issue for the keyword set selenium speed

Add some value to set selenium speed
you can use something like this set selenium speed 2 it will wait for two minutes

Related

Selenide-How to maximise the browser window

After Selenide 6.0.1 version they deleted Configuration.startMaximized. How can we maximize browser now?
Just use the pre-defined size of the browser, it helps you to avoid unexpected behavior in tests, especially on remote runs.
Configuration.browserSize = "1920x1080";

Selenium WebDriver in Ruby: Preventing the test from closing the browser window at end

I appear to be having the exact opposite problem many other people have - in that my Selenium tests in Ruby will close the browser window at test end, no matter what the end result is. Pass or fail, it will always close the browser. I would like to stop this.
Context:
Previously I coded tests in Java using IntelliJ IDEA. Browser windows for Selenium tests in this case would NOT close at all period unless you used driver.quit(). This is actually quite useful as it means that the browser window would stay open if the test failed - which meant I could look at where it stopped in the browser and help figure out why it failed. This was also useful for test writing as it meant that I could essentially pick up where I left off to write the next block instead of having to keep a parallel tab going in another browser by hand to get the next set of selectors in the given screen.
I've found in Ruby using RubyMine that the browser will close when the test ends in any capacity. This is a bit of a problem. While technically I could take a screencap on failure, it'd mean that I'd have a harder time retracing why it failed (back button on browser, typing in fields to work out if a quirk in our UI caused it, etc). And of course, screencaps take up hard drive space. ;)
I've tried the detach=true (and True) command switch for Chrome and that has not worked.
Setup:
IDE: RubyMine
Gems: selenium-webdriver
Browser: Chrome, using ChromeDriver. (In Ruby this just involves using WebDriver)
OS: OSX
Not headless, using no other frameworks/testing environments. It is quite literally a few lines of setup and then hitting the run button in RubyMine in a bog-standard .rb.
Summary:
I haven't been able to find any existing questions here or in other places online for Ruby specifically for keeping a Selenium test in RubyMine from closing the window on test end. "Test end" in this case refers to success (reaching the end of the .rb) or failure (Tracebacks, in this case). I would prefer that the window would stay open until it'd hit a driver.quit line. Is there any way I can set this up?
Thank you very much. I hope this isn't redundant. I also hope this will help other testers in the future :)
You can use the :desired_capabilities to set this flag:
caps = Selenium::WebDriver::Remote::Capabilities.chrome("goog:chromeOptions" => {detach: true})
driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
Note that old examples will be using "chromeOptions", but for newer Chrome versions, it will need to be "goog:chromeOptions".
#JustinKo has posted an answer here
Chrome detach option is no longer working
You can pass Chrome Options using the following format:
browser = Watir::Browser.new(
:chrome,
'goog:chromeOptions' => {detach: true}
)
The answer from #Justin Ko worked for me. However at the time of posting I am getting a warning telling me to use
capabilities: caps
instead of
desired_capabilities: caps
as it is now currently deprecated at the time of posting.
I do not have enough reputation to be able to comment so I am posting this as an answer.

ie11 should start new session every time when run with robot framework but it's unable start new session

I was trying to implement a robot framework automation test for a sign-in page.when I run with IE browser the session wasn't closing for the 1st user and the user is in login even after using "Delete All Cookies" keyword for the 2nd user.This is only happening for IE11 browser and rest of the browsers(chrome, Firefox and Edge) are working fine.
*** Settings ***
Library Selenium2Library
Library OperatingSystem
*** Variables ***
${url_google} https://accounts.google.com/signin
${local_ie_driver}
D:${/}PortableApps${/}SeleniumIEWebDriver${/}IEDriverServer.exe
*** Test Cases ***
Google for macarronada using IE
Set Environment Variable no_proxy 127.0.0.1
Set Environment Variable webdriver.ie.driver ${local_ie_driver}
Open Browser ${url_google} ie
Sleep 2s
Input Text //*[#id='identifierId'] xxxxxxxx#gmail.com
Click Element //*[#id='identifierNext']/content
Sleep 2s
Input Text //*[#id='password']/div[1]/div/div[1]/input abc123xxx#
Click Element //*[#id='passwordNext']
Delete All Cookies
Close Browser
Any Idea ? Has anyone else seen this issue or similar with robot framework?
Internet Explorer by default "shares" session between multiple windows and tabs. Try this option to open new Internet Explorer windows
https://answers.microsoft.com/en-us/ie/forum/ie11-windows_7/new-session-shortcut-for-ie11/1b3e6408-abcd-4dea-8afa-acb7b15e8f71 (i.e., the -noframemerging command line argument for opening Internet Explorer windows). It worked for the situation I was having which is similar to the situation you are presenting.
Let us know if it worked for you.

Close window through Capybara

I am trying to launch the browser for the capybara automation. The browser is auto populating a "Error window" (non-browser window).
I need to "close/click ok" on the window to open the browser. I tried to handle this popup with the "AutoIT" executable file. When i run the AutoIT file manually, the executable file handles it successfully.
I am not able to execute through the capybara script. The code is as below
ses = Capybara::Session.new(:selenium)
IO.popen('c:\ruby\handler.exe') #- Tried this step to execute AutoIT .exe file before visit url step.
No luck here. The popup appears only when referencing with the object.
ses.execute_script "window.close()" #- Tried this step to close the window with the ses object. no luck in this too.
ses.visit "https://google.com"
Is there a way to close the window programmatically?
It seems that you should be able to register a custom selenium driver using the Chrome browser and specify the command-line option to disable all extensions, with the following driver registry code:
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome,
:switches => %w[--disable-extensions])
end
ses = Capybara::Session.new(:selenium)
...
I put this together using information here and the list of available command line options here (I did not test this myself though).
There are a few approaches to a popup error like that:
1) The easiest one is to do your approach - execute an autoit script before calling capybara to visit the site that results in the error popping up. You should ensure that the autoit script you are executing waits for the window to appear before trying to close it (see: https://www.autoitscript.com/autoit3/docs/functions/WinWait.htm for reference).
2) You could execute another ruby script/thread (keep in mind threading in ruby is a bit complicated) that would execute the autoit script in the background (in a loop) and wait for a succesfull response.
3) You could try to disable whatever is causing the error to pop up in your browser.
I will be able to provide some code following approaches 1 and 2 in a few hours if you will still have problems solving the issue.
The error Failed to load Extension. Loading of unpacked extensions are disabled by administrator. indicates that your system was set-up to disable extensions with Chrome. So even if you manage to close it, you probably won't be able to automate Chrome with Selenium since it needs to start Chrome with the driver as an extension.
Your best chance to make it work is probably to disable the restriction or to add the extension to the white list.
Here is a link about this issue:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=639

Selenium & Firefox: How can i turn off "Unresponsive script" warnings?

I'm using Selenium Client 2.4.0 on Mac 10.6.6 with Firefox 5. Using the WebBackedSeleniumDriver, I'm running a "selenium.getEval" command that causes a Firefox warning,
"Warning: Unresponsive script.
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
Script: resource://fxdriver/modules/utils.js:9161"
The value of "dom.max_script_run_time" about:config was "0", which should disable the above dialog altogether. Yet, I still get the dialog. Is there any way to prevent the warning dialog from appearing?
dom.max_script_run_time is the right preference but it only applies to web pages. Browser UI (and extensions like fxdriver are part of it) are restricted by the preference dom.max_chrome_script_run_time however (default value is 20 seconds). You should set it to 0 as well.
Documentation: https://developer.mozilla.org/en/Preferences/Mozilla_preferences_for_uber-geeks#DOM_preferences
Regardless of what you have setup in your profile, during startup, Selenium sets both values to 2417483647 to try and get around the browser warning. However, because the value is so large, FF ends up ignoring it and using the default value of 10/20 instead. This is true even if you're pointing Selenium to use your profile as the template.
The best way I've found to get around this is to specify
-timeout nnnn
to the Selenium Server startup args. This sets both the server and client (browser) timeout values.
Although this thread is quite old, the problem still exists with current selenium and firefox builds. I've got these really annoying messages quite a long time now, without a good fix. Asking the devolopers / mailing list / google usually results in the following answer:
The javascript used in your application is too fat or buggy, improving your scripts will help.
As this is no option in a larger company, when you depend on a framework you have no access to, i decided to search for the root cause for myself.
The core of the problem is the fact, that selenium overrides profile settings if you specify the -timeout nnnn parameter. So creating a custom firefox profile template and setting the dom.max_script_run_time and dom.max_chrome_script_run_time will not work here.
As soon as you specify the -timeout parameter, these two settings are overriden with the value you provide to the parameter. After hours of debugging and testing i noticed some facts:
If you don't specify -timeout, firefox runs for exact 30 minutes, without one script timeout. After that, firefox gets killed by selenium with a SeleniumCommandTimedOutException
As soon as you specify -timeout (no matter which value), the script timeout appears after several seconds or minutes. These messages are independent to the timeout-value.
The -browserTimeout parameter isn't usefull as i haven't found where this parameter is used in the source.
As we have some testsuites that run longer than 30 minutes we have 2 options to fix this behaviour:
Rewriting our testsuites and splitting them to run within the 30 minutes window
Patching selenium to run longer than 30 minutes
Do not use the -timeout parameter.
So choose for yourself which option is better. I created a small and simple patch for the HTMLLauncher.java to allow 90 minutes instead of the default 30.
diff --git a/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java b/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
index c2296a5..310b39f 100644
--- a/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
+++ b/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
## -146,6 +146,16 ##
launcher.launchHTMLSuite(suiteURL, browserURL);
sleepTight(timeoutInMs);
+ // SFR, Patch 2013-10-17: To get rid of the damn SeleniumCommandTimedOutException
+ // we allow the Suite to run 3 times as long as per default (30 min -> 90 min).
+ if(results == null) {
+ log.warning("SFR, Patch 2013-10-17");
+ sleepTight(timeoutInMs);
+ }
+ if(results == null) {
+ log.warning("SFR, Patch 2013-10-17");
+ sleepTight(timeoutInMs);
+ }
launcher.close();
I'll upload a pre-compiled jar with the above patch if necessary.
Go the hidden configuration page in Firefox by typing about:config in the address bar . (make sure that you are doing this for the profile you are using for selenium) In the 'Filter' box, type script_run_time.
This will narrow the options to dom.max_script_run_time and dom.max_chrome_script_run_time. Right-click it and choose Modify. A box pops up. Change the number to something bigger like 40. This is the maximum time a script can run before Firefox considers it 'unresponsive'. If you can’t find the string in the about:config page, create it by right-clicking anywhere and then choose New—> Integer and enter there name and values (when asked)
Set it to a very large number instead of "20"?
The dom.max_script_run_time setting is in seconds. Changing it from 10 to 20 just doubles the amount of time to wait. A value of 0 will disable it, but this could result in a run-away script locking up your browser. You might just use a really large value.
More details here:
http://kb.mozillazine.org/Dom.max_script_run_time
This issue appears for me when I do Selenium calls while web application is running some own crappy slow JS. Even if I catch the popup and retry after few seconds, FF is not responsive to Selenium anymore. The solution is to just put sleep 10 before otherwise any Selenium call would result in popup.

Resources