Git Product home page Git Product logo

marketsquare / robotframework-seleniumtestability Goto Github PK

View Code? Open in Web Editor NEW
38.0 14.0 13.0 626 KB

Extension for SeleniumLibrary that provides manual and automatic waiting for asyncronous events like fetch, xhr, etc.

License: Apache License 2.0

Python 66.31% RobotFramework 10.85% HTML 13.89% JavaScript 3.37% CSS 5.58%
robotframework robot-framework selenium testability hacktoberfest hacktoberfest2020

robotframework-seleniumtestability's Introduction

robotframework-seleniumtestability

SeleniumTestability is a plugin to Robot Framework's SeleniumLibrary that adds functionality to it doesn't fit into its mission. These new features are archived by SL's plugin api that then automatically instrumentents the web application via javascript calls and provides keywords to bridge those into Robot Framework.

Plugin provides automatic detection of asyncronous events happening within the web application. For example, if a rest api is called from the application, testcase can automatically wait for that call to finish before doing any interaction in the UI. There's also a bunch of functionality like fetching of browser logs, keywords to interact with local and session storage. See the keyword documentation here for more details.

SeleniumTestability relies on core Selenium's feature EventFiringWebdriver and provides it's own listener interface that takes care of waiting in right places and instrumenting the SUT whenever it is needed.

In the future, its also possible to extend the javascript parts of SeleniumTestability to incorporate more state inspections.

Monitoring of the asyncronous events is archived with help of Testability.js and its bindings

Support

"Official" support channel available in Gitter.im

Installation

pip install robotframework-seleniumtestability

Usage

Initialize library

Library         SeleniumLibrary     plugins=SeleniumTestability;True;30 Seconds;True

For parameter descriptions, refer to keyword docmentation.

Example

  Click Element             id:button_that_triggers_ajax_request
  Click Element             id:some_other_element
  Log To Console            This will happen right after clicking

In here, if automatic_wait has been enabled, second Click Element keyword wont be executed before action triggered by the first button is finished.

If automatic_wait is not enabled, test case can request the wait itself and previous example would look something like this.

  Click Element               id:button_that_triggers_ajax_request
  Wait For Testability Ready
  Click Element               id:some_other_element
  Wait For Testability Ready
  Log To Console              This would show after events triggered by second click are done.

Currently Supported Asyncronous features

  • setTimeout & setImmediate calls and wait for them.
  • fetch() call and wait for it to finish
  • XHR requests and wait for them to finish
  • CSS Animations and wait form them to finish
  • CSS Transitions and wait form them to finish
  • Viewport scrolling.

Do note that catching css animations and transitions is browser dependant. In the past certain browsers did not implement these features as "the standard" would require.

Other functionality.

SeleniumTestability also provides other conveniance keywords that do not make sense to incorporate into SeleniumLibrary itself, mainly due to functionality not being in scope of SeleniumLibrary and Selenium python bindings. Do check the keyword documentation for up to date list of keywords.

Keyword Documentation

Keyword documentation here and if you need to create one for offline usage:

python -m robot.libdoc SeleniumLibrary::plugins=SeleniumTestability

Contributing

CONTRIBUTING.md documents how to setup the environment for further development of SeleniumTestability.

robotframework-seleniumtestability's People

Contributors

avimehenwal avatar emanlove avatar rasjani avatar royari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotframework-seleniumtestability's Issues

No keyword with name 'Set Storage Item' found.

Hi, Please find bellow test cases

*** Settings ***
Documentation     A test suite with a single test for valid login.
...
...               This test has a workflow that is created using keywords in
...               the imported resource file.
Resource          resource.robot
Library           SeleniumLibrary   plugins=SeleniumTestability;True;30 Seconds;True
Library           Collections


*** Test Cases ***
Valid Login
    Open Browser To Login Page
    Set Storage Item  ${key}    ${value}    storage_type=sessionStorage
    Success Page Should Be Open
    [Teardown]    Close Browser

When I run test cases I am getting bellow error

Valid Login :: A test suite with a single test for valid login.               
==============================================================================
Valid Login                                                           | FAIL |
No keyword with name 'Set Storage Item' found.
------------------------------------------------------------------------------
Valid Login :: A test suite with a single test for valid login.       | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed

Error log

2020-07-20 09:19:54,245 - SeleniumTestability - DEBUG -  **** New Session Created for SeleniumTestability  **** 
2020-07-20 09:19:54,245 - SeleniumTestability - DEBUG - __init__(<SeleniumLibrary.SeleniumLibrary object at 0x10cd5ff40>,True,30 Seconds,True,True)

Versions

robotframework==3.2.1
robotframework-seleniumlibrary==4.4.0
robotframework-seleniumtestability==1.1.0
selenium==3.141.0

Add support for localstorage set/get

Add support for setting / getting and deleting values from localStorage & sessionStorage.

Most of this is easy to dict types within localStorage should do some json parsing.

Tests for scrolling

Sub tasks:

  1. make the flask test application (or some sub page of it) in assets/ to be atleast twice as big as a running viewport
  2. add new suite that uses all scrolling keywords
  3. Verifies that scrolling pends while scrolling is happening.

Sometimes testability wait for just 5 seconds even it's more than that in settings

Expected Behavior

  • SeleniumTestability should wait for 30 seconds instead of 5 secs

Actual Behavior

  • SeleniumTestability wait for 5 secs and raise a timeout exception

Steps to Reproduce the Problem

  1. Execute the robot test file as an example below
    https://pastebin.com/XRfDwR4e

Specifications

  • selenium python package version: 3.141.0
  • SeleniumLibrary version: 4.1.0
  • SeleniumTestability version: 0.0.15
  • Operating System: Windows
  • Browser Version: Chrome 78
  • WebDriver Version: Chromedriver 78

SeleniumTestability Log URL

https://pastebin.com/pp1NFZxc

Robot output.xml URL

https://pastebin.com/b5j0qa5v

Add support for Touch events

Webdriver spec has commands to generate touch events but SeleniumLibrary doesn't support these yet. Implement in Testability

After using seleniumtestability ;seleniumtestability specific keywords I am not able to access in the test case

Keep bug reports clean, remove any unnecessary fields and fill in all the information you can. Explain what you where expecting and what you are actually seeing.

And please, direct support questions to #seleniumtestability channel in Robot Framework slack.

In order to help you, run your robot framework tests with --loglevel TRACE:TRACE and attach SeleniunTestability.log from RF's output either as github gist or pastebin link.

Expected Behavior

Actual Behavior

Steps to Reproduce the Problem

Specifications

  • SeleniumTestability version:
  • Operating System:
  • Browser Version:
  • WebDriver Version:

Log URL

feature request: ability to scope down the request waiting

Background: sometimes in our staging we face a problem with 3rd party components (analytics and digital marketing to track the event) from time to time so it would be great if we can have this kind of the ability to scope down the request waiting for just the url we are interested (our system under test of course)

get log keyword returns internal firefox javascript logs when it shouldnt

Expected Behavior

atest/logs.robot should pass on all platforms.

Actual Behavior

Fails on windows firefox because there´s rows in geckolog that are not in other platforms.

Steps to Reproduce the Problem

  1. run current atest/logs.robot on windows

Specifications

  • SeleniumTestability version: current
  • Operating System: windows
  • Browser Version: latest
  • WebDriver Version: latest

Open New Window

Implement Open New Window keyword.

optional arguments url and switch_to

Get / Set browser geocoordinates.

Patching:

        window.navigator.geolocation.getCurrentPosition = function(success) {
            var position = {
                "coords" : {
                    "latitude": "%s",
                    "longitude": "%s"
                }
            };
            success(position);
        }'''
            % cords
        )

and fetching:

    def get_coordinates(self) -> tuple:
        latitude = self.execute_script(
            '''
        latitude = ""
        window.navigator.geolocation.getCurrentPosition(function(pos) {
            latitude = pos.coords.latitude
        });
        return latitude
        '''
        )

        longitude = self.execute_script(
            '''
        longitude = ""
        window.navigator.geolocation.getCurrentPosition(function(pos) {
            longitude = pos.coords.longitude
        });
        return longitude
        '''
        )

from https://github.com/dillonm197/extended-webdrivers/blob/master/extended_webdrivers/extended_webdriver.py

Load / Save Cookies To File

Implement a feature to save and load cookies to a file.

Would allow sharing some session data between different browsers and/or run sessions.

Host images locally for tests.

if test running environment is not able to load the images, tests will fail as no animations or transitions are done towards missing images.

Errors with Selenium 4.0.0.b3

Hello,

I apologize as I am new to this, but wanted to see if there is a work around for this.

When using Selenium Library version 4.0.0b3 I am getting the follow error below, yet when using version 3.141.0 it will run successfully. We installed the latest version of Selenium to test against Edge browser. Do you have a fix for this?

[ ERROR ] Error in file ‘C:\GIT\Repos\Eclipse\UPEnterprise_Robot\tests\Regressions\UPExchange\UPXREGEditProperties.robot’ on line 2: Initializing library ‘SeleniumLibrary’ with arguments [ plugins=SeleniumTestability;False;5 Seconds;True ] failed: Importing test library ‘SeleniumTestability’ failed: AttributeError: type object ‘DesiredCapabilities’ has no attribute ‘PHANTOMJS’
Traceback (most recent call last):
File “C:\AppData\Local\Programs\Python\Python37\lib\site-packages\SeleniumTestability_init_.py”, line 2, in
from .plugin import SeleniumTestability
File “C:\AppData\Local\Programs\Python\Python37\lib\site-packages\SeleniumTestability\plugin.py”, line 43, in
class SeleniumTestability(LibraryComponent):
File “C:\AppData\Local\Programs\Python\Python37\lib\site-packages\SeleniumTestability\plugin.py”, line 148, in SeleniumTestability
“phantomjs”: DesiredCapabilities.PHANTOMJS,
PYTHONPATH:
C:\GIT\Repos\Eclipse\UPEnterprise_Robot
C:\AppData\Local\Programs\Python\Python37\python37.zip
C:\AppData\Local\Programs\Python\Python37\DLLs
C:\AppData\Local\Programs\Python\Python37\lib
C:\AppData\Local\Programs\Python\Python37
C:\AppData\Roaming\Python\Python37\site-packages
C:\AppData\Local\Programs\Python\Python37\lib\site-packages

Expected Behavior

Drag and drop works correctly

Actual Behavior

Test throw errors right at the beginning and when it reaches drag and drop it fails the test

Steps to Reproduce the Problem

  1. Upgrade to 4.0.0b3
  2. Run any test that has seleniumtestability
  3. Run test with drag and drop

robotframework==4.0.1
robotframework-pythonlibcore==2.2.1
robotframework-requests==0.8.0
robotframework-selenium2library==3.0.0
robotframework-seleniumlibrary==5.1.3
robotframework-seleniumtestability==1.1.0
selenium==3.141.0

Add support for external instrumentation file

Currently, the instrumentation file is generated by release time and shipped within the python package.

It would be beneficial that users of SeleniumTestability to provide their own instrumentation.

One approach could be to publish the js part of our code as npm, then allow people to publish (or have a local copy) their own copy which could be taken into use at runtime to pointing some sort of environment variable to the package.

Testability automatic wait is enabled after test case fails

So I have a problem where testability automatic wait is somehow enabled after a test fails. I've used Disabled Testability Automatic Wait in the suite setup to disable it during the suite execution. When a test fails inside the suite, it moves on to the next test (as robot should) and the first selenium keyword that is executed fails with this error: TimeoutException: Message: Timed out waiting for testability ready callback to trigger. This is problematic as a single failed test will fail all of the tests that come after it in the testsuite.

As a test I put a call for Disabled Testability Automatic Wait as the first step in the test case that causes this TimeoutException, and the test passed. This leads me to believe that the automatic wait is somehow enabled after test failure.

Expected Behavior

Testability automatic wait should not be enabled at runtime automatically. If testability automatic wait is disabled in the setup, it should stay disable during the suite.

Actual Behavior

Testability automatic wait is enabled after any test case fails.

Steps to Reproduce the Problem

  1. Create suite with more than 1 test case
  2. Import seleniumlibrary with the testability plugin
  3. Create suite setup that disables testability automatic wait
  4. Make it so that the first test case fails. (fe. wait for element that is not present)
  5. Run the suite

Specifications

  • SeleniumTestability version: 1.1.0
  • Operating System: WIN10-Pro 64bit
  • Browser Version: Chrome 85.0.4183.102
  • WebDriver Version: ChromeDriver 85.0.4183.83

Log URL

SeleniumTestability.log

I have also enclosed the failing keyword stacktrace from the html.log file: HtmlLog

Unable to generate libdoc because of circular dependency in Python install files

I was trying to generate the libdoc for SeleniumTestability using the following command in Command Line:
python -m robot.libdoc SeleniumLibrary::plugins=SeleniumTestability

However, it ends in an error message as follows:

Could not import runpy module
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 14, in
import importlib.machinery # importlib first so we can test #15386 via -m
File "C:\Program Files\Python39\lib\importlib_init_.py", line 57, in
import types
File "C:\Program Files\Python39\Lib\site-packages\SeleniumTestability\types.py", line 2, in
from typing import Union, Optional, List, Dict
File "C:\Program Files\Python39\lib\typing.py", line 23, in
import contextlib
File "C:\Program Files\Python39\lib\contextlib.py", line 6, in
from functools import wraps
File "C:\Program Files\Python39\lib\functools.py", line 22, in
from types import GenericAlias
ImportError: cannot import name 'GenericAlias' from partially initialized module 'types' (most likely due to a circular import) (C:\Program Files\Python39\Lib\site-packages\SeleniumTestability\types.py)

Any ideas on how to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.