Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript error trap #68

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1091b4d
Changes to allow any remote URL to be passed in for grid, not just cr…
Oct 28, 2016
7483afc
Merge pull request #1 from conversica-aaronpa/remote_url
conversica-aaronpa Oct 28, 2016
0fb3b2c
Notes and a tiny bit of code to support self starting on use of this …
Nov 28, 2016
4cc3904
Merge pull request #2 from conversica-aaronpa/quickstart
conversica-aaronpa Nov 28, 2016
bd2af3b
Formatting, typos
Nov 28, 2016
28646d3
Merge pull request #3 from conversica-aaronpa/quickstart
conversica-aaronpa Nov 28, 2016
cba9d64
More typo
conversica-aaronpa Nov 28, 2016
b3d7698
Now remote_url parameter now does not require sauce parameters, unles…
Nov 29, 2016
8889edf
Merge pull request #4 from conversica-aaronpa/remote_url
conversica-aaronpa Nov 29, 2016
b5cc229
Merge pull request #1 from ncbi/master
conversica-aaronpa Mar 21, 2017
4cf6780
Addition of some default settings via DesiredCapabilities for Chrome,…
conversica-aaronpa Apr 24, 2017
e642cea
Merge pull request #5 from conversica-aaronpa/chrome-default-caps
conversica-aaronpa Apr 24, 2017
4d1f541
Better way to increase node count is via docker-compose command line …
conversica-aaronpa Apr 29, 2017
51efefb
More data in Sauce console to make it easier to match runs
conversica-aaronpa May 31, 2017
c1622d0
Merge pull request #6 from conversica-aaronpa/Sauce_title_status
conversica-aaronpa May 31, 2017
e5e9dcd
Revert "Sauce title status"
conversica-aaronpa May 31, 2017
90e72e0
Merge pull request #7 from AVAai/revert-6-Sauce_title_status
conversica-aaronpa May 31, 2017
845e7e9
Changes to get correct suite status into Sauce console
conversica-aaronpa Jun 2, 2017
1ca135c
Merge pull request #8 from conversica-aaronpa/Sauce_title_status
conversica-aaronpa Jun 2, 2017
160ab2b
Removing much of reliance on implicit wait, some code will now requir…
conversica-aaronpa Jun 13, 2017
92cdb09
Merge pull request #9 from conversica-aaronpa/master
conversica-aaronpa Jun 13, 2017
c0cde1b
Adding basic support for Applitools Eyes
conversica-aaronpa Jun 23, 2017
f72106f
Merge pull request #10 from conversica-aaronpa/applitools_eyes
conversica-aaronpa Jun 23, 2017
4153a7c
Changes to work better with Applitools Eyes
conversica-aaronpa Jun 27, 2017
6eafe9c
Merge pull request #11 from conversica-aaronpa/applitools_eyes
conversica-aaronpa Jun 27, 2017
bda9dd8
More logging, corrected error on calling eyes.close
conversica-aaronpa Jun 29, 2017
a679fcd
Merge pull request #12 from conversica-aaronpa/applitools_eyes
conversica-aaronpa Jun 29, 2017
b2acc83
Changes to warn on screen capture mismatch but let test continue
conversica-aaronpa Jul 3, 2017
ed007bb
Merge pull request #13 from conversica-aaronpa/applitools_eyes
conversica-aaronpa Jul 3, 2017
a63f544
Changes to get Sauce Labs test status recording working
conversica-aaronpa Jul 26, 2017
b42a116
Merge pull request #14 from conversica-aaronpa/sauce_rest_url_patch
conversica-aaronpa Jul 26, 2017
0d07298
Additional Desired Capabilities for Sauce Connect VPN
conversica-aaronpa Aug 4, 2017
9021f7c
Merge pull request #15 from conversica-aaronpa/sauce_connect
conversica-aaronpa Aug 4, 2017
21ce2cd
Adding batch_id for Eyes part of interface to consolidate like name b…
conversica-aaronpa Aug 14, 2017
891b7be
Merge pull request #16 from conversica-aaronpa/eyes_batch_id
conversica-aaronpa Aug 14, 2017
bd2af2d
For IE, make sure we're using later Selenium
conversica-aaronpa Sep 9, 2017
5592b13
Merge pull request #17 from conversica-aaronpa/IE-gets-new-Se
conversica-aaronpa Sep 9, 2017
03098a3
Prevent use of force full page screenshot and CSS stitchmode for IE o…
conversica-aaronpa Sep 11, 2017
c8efdda
Merge pull request #18 from conversica-aaronpa/Sauce-IE-no-fullpage-Eyes
conversica-aaronpa Sep 11, 2017
0264016
Update page.py
conversica-aaronpa Sep 14, 2017
9beb089
Merge pull request #2 from conversica-aaronpa/IE-version
conversica-aaronpa Sep 14, 2017
42d7616
Merge pull request #19 from conversica-aaronpa/master
conversica-aaronpa Sep 14, 2017
a4a48b9
Adding some duration tracking and changing match level to see how it …
conversica-aaronpa Oct 5, 2017
1084b48
Merge pull request #20 from conversica-aaronpa/master
conversica-aaronpa Oct 5, 2017
9bb1e0d
Changing match level and logging calculated durations
conversica-aaronpa Oct 5, 2017
b0d0412
Merge pull request #21 from conversica-aaronpa/eyes-duration
conversica-aaronpa Oct 5, 2017
9168199
Go back to strict matching for now
conversica-aaronpa Oct 19, 2017
29be414
Merge pull request #22 from conversica-aaronpa/matchlevel-strict
conversica-aaronpa Oct 19, 2017
2c2fd6b
Trying layout2 as default page matching
conversica-aaronpa Oct 31, 2017
d925825
Merge pull request #23 from conversica-aaronpa/matchlevel-layout2
conversica-aaronpa Oct 31, 2017
78c34a5
Try a different level of match for visual tests. TODO: parameterize t…
conversica-aaronpa Nov 1, 2017
cbac8fa
Merge pull request #24 from conversica-aaronpa/matchlevel-content
conversica-aaronpa Nov 1, 2017
e549e08
Trying LAYOUT2 again
conversica-aaronpa Dec 13, 2017
f6c8008
Merge pull request #25 from conversica-aaronpa/matchlevel-layout2
conversica-aaronpa Dec 13, 2017
634a95f
Add optional match level parameter to Eyes Open keyword
conversica-aaronpa Mar 2, 2018
f0acd2a
Merge pull request #26 from conversica-aaronpa/match-level-param
conversica-aaronpa Mar 2, 2018
2ce4044
Pin newer versions of IE driver and Selenium for IE
conversica-aaronpa May 1, 2018
af12720
Merge pull request #27 from conversica-aaronpa/ie-selenium-versions
conversica-aaronpa May 1, 2018
9db2f6e
3.11 versions not working so well, trying with unspecified versions
conversica-aaronpa May 1, 2018
b91dc4d
Merge pull request #28 from conversica-aaronpa/ie-selenium-versions
conversica-aaronpa May 1, 2018
5c0f4f6
Adding a keyword to report any javascript errors on the page, throw o…
conversica-aaronpa Aug 8, 2018
253078a
Merge branch 'master' into javascript-error-trap
conversica-aaronpa Aug 8, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Robot Framework Page Objects - Quick Start


## Installation and Setup
Clone this repository to a Linux system, open a terminal in the cloned directory

Verify python is available.

Using pip, install from the requirements.txt file in this directory with:
`$ pip install -r requirements.txt`

Find and download [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads), make sure it is in your path:
`$ which chromedriver`
`/home/aaronpa/chromedriver/chromedriver`

## Running an example
`$ pybot -v baseurl:http://www.conversica.com open_capture.robot`

## Video of Setup and Running
[Screencast video demo](http://screencast.com/t/jhf74SbtYv5) - Note: browser activity not picked up by screen capture, but can be seen live instead of white canvas areas seen in this screen capture.

### What the example does
Starting with the open_capture.robot file, a resource file is read, common.robot. In that file some external library references are defined, as well as the browser type, and browser width and height. The pybot python robot test runner provides for these variables to be overridden via command line - the width of the test run can be changed for each run.

Once the test starts, the browser is opened to the value found in the `baseurl` variable. Selenium will wait for the page to load entirely before proceeding.

The `Startup` and `Shutdown` keywords are defined in common.robot, but not executed. They are called via the Suite Setup and Suite Teardown settings at the stop of open_capture.robot.

After the suite has started and the browser is open and on the intended target, the test logic can begin. In this example test, all links are scraped off of the page using a CSS locator expression. They are then logged from a FOR loop so that the href target for each link is written out. This example test has no assertions and is intended to simply demonstrate the supporting software.


29 changes: 29 additions & 0 deletions common.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*** Settings ***
Library Selenium2Library
Library robotpageobjects.Page
Library uuid

*** Variables ***
${width} 1024
${height} 768
${browser} chrome

*** Keywords ***
Save Selenium Screenshot
[documentation] Make sure there is a unique name to prevent overwriting
${screenshot_index}= Get Variable Value ${screenshot_index} ${0}
Set Global Variable ${screenshot_index} ${screenshot_index.__add__(1)}
${time}= Evaluate str(time.time()) time
Capture Page Screenshot selenium-screenshot-${time}-${screenshot_index}.png

Startup
[documentation] Initial work to be completed in suite startup
Register Keyword To Run On Failure Save Selenium Screenshot
Open ${baseurl}
Set Window Size ${width} ${height}

Shutdown
[documentation] Final record keeping, cleanup
Capture Page Screenshot end.png
Close

11 changes: 11 additions & 0 deletions open_capture.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*** Settings ***
Resource common.robot
Suite Setup Startup
Suite Teardown Shutdown
Force Tags quickstart

*** Test Cases ***
Sample Test
${links}= Get Web Elements css=a
:FOR ${some link} IN @{links}
\ Log ${some link.get_attribute('href')}
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
robotframework-selenium2library
robotframework-pageobjects
decorator
mock==1.0.1
requests==2.1.0
robotframework<3
robotframework-selenium2library==1.7.2
uritemplate==0.6
2 changes: 1 addition & 1 deletion robotpageobjects/abstractedlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):

# Stream handler is attached from log() since
# that must be decided at run-time, but here we might as well
# do the setup to keep log() clean.
# do the client_setup to keep log() clean.
self.stream_handler = logging.StreamHandler(sys.stdout)
self.stream_handler.setFormatter(self.formatter)

Expand Down
12 changes: 1 addition & 11 deletions robotpageobjects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ class _BaseActions(_S2LWrapper):
_abstracted_logger = abstractedlogger.Logger()

def __init__(self, *args, **kwargs):
"""
self.class__ = """
Initializes the options used by the actions defined in this class.
"""
#_ComponentsManager.__init__(self, *args, **kwargs)
Expand All @@ -553,8 +553,6 @@ def __init__(self, *args, **kwargs):
self.set_selenium_speed(self.selenium_speed)
siw_opt = self._option_handler.get("selenium_implicit_wait")
self.selenium_implicit_wait = siw_opt if siw_opt is not None else 10
self.set_selenium_implicit_wait(self.selenium_implicit_wait)
self.set_selenium_timeout(self.selenium_implicit_wait)

self.baseurl = self._option_handler.get("baseurl")

Expand Down Expand Up @@ -710,16 +708,10 @@ def _element_find(self, locator, *args, **kwargs):
if isinstance(locator, WebElement):
return locator

our_wait = self.selenium_implicit_wait if kwargs.get("wait") is None else kwargs["wait"]

# If wait is set, don't pass it along to the super classe's implementation, since it has none.
if "wait" in kwargs:
del kwargs["wait"]


self.driver.implicitly_wait(our_wait)


if locator in self.selectors:
locator = self.resolve_selector(locator)

Expand All @@ -732,8 +724,6 @@ def _element_find(self, locator, *args, **kwargs):
"\"%s\" is not a valid locator. If this is a selector name, make sure it is spelled correctly." % locator)
else:
raise
finally:
self.driver.implicitly_wait(self.selenium_implicit_wait)

@not_keyword
def find_element(self, locator, required=True, wait=None, **kwargs):
Expand Down
Loading