Skip to content

Commit

Permalink
Set log source default level to TRACE. (#1244)
Browse files Browse the repository at this point in the history
Change most of the keywords loglevel to TRACE.
  • Loading branch information
joaonc authored and aaltat committed Dec 8, 2018
1 parent a5af615 commit ed9498d
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 84 deletions.
2 changes: 1 addition & 1 deletion atest/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ from the `.travis.yam`_. Generally speaking the test are automatically run
by using Chrome and Firefox browsers. The project uses Python 2.7, Python 3.4,
Python 3.6 and PyPy 3.5 for test execution. The project uses and latest available
Selenium 3 version for test execution. Test uses Robot Framework versions
2.9.2 and 3.0.2 for acceptance test execution.
2.9.2 and 3.0.4 for acceptance test execution.

.. _browser driver: https://github.com/robotframework/SeleniumLibrary#browser-drivers
.. _PATH: https://en.wikipedia.org/wiki/PATH_(variable)
Expand Down
1 change: 0 additions & 1 deletion atest/acceptance/big_list_of_naught_strings.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Big List Of Naughty Strings
:FOR ${string} IN @{blns}
\ Check Blns Error Check ${string}


*** Keywords ***
Check Blns Error Check
[Arguments] ${string}
Expand Down
1 change: 0 additions & 1 deletion atest/acceptance/extending.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Suite Teardown ExtSeLib.Close All Browsers
Resource resource.robot
Library ExtSL.ExtSL WITH NAME ExtSeLib


*** Test Cases ***
When Extending SeleniumLibrary Keywords With Decorated Name Can Be Used For Extending
${elements} = ExtSeLib.Ext Web Element //tr
Expand Down
1 change: 0 additions & 1 deletion atest/acceptance/keywords/click_element_modifier.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Suite Setup Go To Page "javascript/click_modifier.html"
Test Setup Initialize Page
Resource ../resource.robot


*** Test Cases ***
Click Element Modifier CTRL
Click Element Button modifier=CTRL
Expand Down
46 changes: 27 additions & 19 deletions atest/acceptance/keywords/content_assertions.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Location Should Be
... Location should have been 'non existing' but was 'http://localhost:7000/html/'.
... Location Should Be non existing message=None


Location Should Contain
[Documentation] LOG 2:4 Current location contains 'html'.
Location Should Contain html
Expand All @@ -36,7 +35,6 @@ Location Should Contain
... Location should have contained 'not a location' but it was 'http://localhost:7000/html/'.
... Location Should Contain not a location message=None


Title Should Be
[Documentation] LOG 2:4 Page title is '(root)/index.html'.
Title Should Be (root)/index.html
Expand All @@ -47,26 +45,36 @@ Title Should Be
... Page title was not expected
... Title Should Be not a title message=Page title was not expected


Page Should Contain
[Documentation] LOG 2:7 Current page contains text 'needle'.
... LOG 4.1:14 REGEXP: (?i)<html.*</html>
[Documentation] The last step fails and doesn't contain the html content.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 2:7 Current page contains text 'needle'.
... LOG 3:7 INFO Current page contains text 'This is the haystack'.
... LOG 4:14 FAIL Page should have contained text 'non existing text' but did not.
Page Should Contain needle
Page Should Contain This is the haystack
Run Keyword And Expect Error
... Page should have contained text 'non existing text' but did not.
... Page Should Contain non existing text
Page Should Contain non existing text

Page Should Contain with text having internal elements
Page Should Contain With Text Having Internal Elements
Page Should Contain This is the haystack and somewhere on this page is a needle.
Go to page "links.html"
Page Should Contain Relative with text after

Page Should Contain With Custom Log Level
[Documentation] LOG 2.1:14 DEBUG REGEXP: (?i)<html.*</html>
Run Keyword And Expect Error
... Page should have contained text 'non existing text' but did not.
... Page Should Contain non existing text DEBUG
Page Should Contain With Custom Log Level DEBUG
[Documentation] Html content is shown at DEBUG level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 2:14 DEBUG REGEXP: (?i)<html.*</html>
... LOG 2:15 FAIL Page should have contained text 'non existing text' but did not.
Page Should Contain non existing text DEBUG

Page Should Contain With Custom Log Level TRACE
[Documentation] Html content is shown at DEBUG level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 3:15 TRACE REGEXP: (?i)<html.*</html>
... LOG 3:16 FAIL Page should have contained text 'non existing text' but did not.
Set Log Level TRACE
Page Should Contain non existing text TRACE
[Teardown] Set Log Level DEBUG

Page Should Contain With Disabling Source Logging
[Documentation] LOG 3:2 NONE
Expand All @@ -81,12 +89,12 @@ Page Should Contain With Frames
Page Should Contain You're looking at right.

Page Should Not Contain
[Documentation] LOG 2:11 Current page does not contain text 'non existing text'.
... LOG 3.1:10 REGEXP: (?i)<html.*</html>
[Documentation] Default log level does not have html output.
... FAIL Page should not have contained text 'needle'.
... LOG 2:11 Current page does not contain text 'non existing text'.
... LOG 3:10 FAIL Page should not have contained text 'needle'.
Page Should Not Contain non existing text
Run Keyword And Expect Error
... Page should not have contained text 'needle'.
... Page Should Not Contain needle
Page Should Not Contain needle

Page Should Not Contain With Custom Log Level
[Documentation] LOG 2.1:10 DEBUG REGEXP: (?i)<html.*</html>
Expand Down
1 change: 0 additions & 1 deletion atest/acceptance/keywords/cookies.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Suite Teardown Delete All Cookies
Test Setup Add Cookies
Resource ../resource.robot


*** Test Cases ***
Get Cookies
${cookies}= Get Cookies
Expand Down
14 changes: 6 additions & 8 deletions atest/acceptance/keywords/counting_elements.robot
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,12 @@ Page Should Contain Element When Limit Is Not Number
... Page Should Contain Element name: div_name limit=AA

Page Should Contain Element When Error With Limit And Different Loglevels
[Documentation]
... LOG 2.1:7 INFO REGEXP: .*links\\.html.*
... LOG 3.1:7 DEBUG REGEXP: .*links\\.html.*
[Documentation] Only at DEBUG loglevel is the html placed in the log.
... FAIL Page should have contained "99" element(s), but it did contain "2" element(s).
... LOG 2.1:7 FAIL Page should have contained "99" element(s), but it did contain "2" element(s).
... LOG 3:7 DEBUG REGEXP: .*links\\.html.*
... LOG 3:8 FAIL Page should have contained "99" element(s), but it did contain "2" element(s).
[Setup] Go To Page "links.html"
Run Keyword And Ignore Error
... Page Should Contain Element name: div_name limit=99
Run Keyword And Ignore Error
... Page Should Contain Element
... name: div_name
... loglevel=debug
... limit=99
Page Should Contain Element name: div_name loglevel=debug limit=99
1 change: 0 additions & 1 deletion atest/acceptance/keywords/screenshot_element.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Documentation Suite description
Suite Setup Go To Page "links.html"
Resource ../resource.robot


*** Test Cases ***
Capture Element Screenshot
[Setup] Remove Files ${OUTPUTDIR}/selenium-element-screenshot-1.png
Expand Down
29 changes: 15 additions & 14 deletions atest/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@

# Folder settings
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
ACCEPTANCE_TEST_DIR = os.path.join(ROOT_DIR, "acceptance")
UNIT_TEST_RUNNER = os.path.join(ROOT_DIR, '..', 'utest', 'run.py')
RESOURCES_DIR = os.path.join(ROOT_DIR, "resources")
RESULTS_DIR = os.path.join(ROOT_DIR, "results")
SRC_DIR = os.path.normpath(os.path.join(ROOT_DIR, "..", "src"))
TEST_LIBS_DIR = os.path.join(RESOURCES_DIR, "testlibs")
HTTP_SERVER_FILE = os.path.join(RESOURCES_DIR, "testserver", "testserver.py")
ACCEPTANCE_TEST_DIR = os.path.join(ROOT_DIR, 'acceptance')
UNIT_TEST_RUNNER = os.path.join(ROOT_DIR, os.pardir, 'utest', 'run.py')
RESOURCES_DIR = os.path.join(ROOT_DIR, 'resources')
RESULTS_DIR = os.path.join(ROOT_DIR, 'results')
SRC_DIR = os.path.normpath(os.path.join(ROOT_DIR, os.pardir, 'src'))
TEST_LIBS_DIR = os.path.join(RESOURCES_DIR, 'testlibs')
HTTP_SERVER_FILE = os.path.join(RESOURCES_DIR, 'testserver', 'testserver.py')
# Travis settings for pull request
TRAVIS = os.environ.get("TRAVIS", False)
TRAVIS_EVENT_TYPE = os.environ.get("TRAVIS_EVENT_TYPE", None)
TRAVIS_JOB_NUMBER = os.environ.get("TRAVIS_JOB_NUMBER", "localtunnel")
SAUCE_USERNAME = os.environ.get("SAUCE_USERNAME", None)
SAUCE_ACCESS_KEY = os.environ.get("SAUCE_ACCESS_KEY", None)
TRAVIS = os.environ.get('TRAVIS', False)
TRAVIS_EVENT_TYPE = os.environ.get('TRAVIS_EVENT_TYPE', None)
TRAVIS_JOB_NUMBER = os.environ.get('TRAVIS_JOB_NUMBER', 'localtunnel')
SAUCE_USERNAME = os.environ.get('SAUCE_USERNAME', None)
SAUCE_ACCESS_KEY = os.environ.get('SAUCE_ACCESS_KEY', None)
TRAVIS_BROWSERS = ['chrome', 'firefox', 'headlesschrome']

ROBOT_OPTIONS = [
Expand All @@ -91,7 +91,7 @@ def unit_tests():
sys.exit(failures)


def acceptance_tests(interpreter, browser, rf_options=[],
def acceptance_tests(interpreter, browser, rf_options=None,
sauce_username=None, sauce_key=None):
if os.path.exists(RESULTS_DIR):
shutil.rmtree(RESULTS_DIR)
Expand Down Expand Up @@ -125,7 +125,8 @@ def execute_tests(interpreter, browser, rf_options, sauce_username, sauce_key):
options = []
runner = interpreter.split() + ['-m', 'robot.run']
options.extend([opt.format(browser=browser) for opt in ROBOT_OPTIONS])
options += rf_options
if rf_options:
options += rf_options
if sauce_username and sauce_key:
options.extend(get_sauce_conf(browser, sauce_username, sauce_key))
command = runner
Expand Down
4 changes: 2 additions & 2 deletions src/SeleniumLibrary/base/librarycomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def log_source(self, loglevel='INFO'):
self.ctx.log_source(loglevel)

def assert_page_contains(self, locator, tag=None, message=None,
loglevel='INFO'):
loglevel='TRACE'):
if not self.find_element(locator, tag, required=False):
self.log_source(loglevel)
if is_noney(message):
Expand All @@ -55,7 +55,7 @@ def assert_page_contains(self, locator, tag=None, message=None,
% (tag or 'element', locator))

def assert_page_not_contains(self, locator, tag=None, message=None,
loglevel='INFO'):
loglevel='TRACE'):
if self.find_element(locator, tag, required=False):
self.log_source(loglevel)
if is_noney(message):
Expand Down
4 changes: 2 additions & 2 deletions src/SeleniumLibrary/keywords/browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def log_source(self, loglevel='INFO'):
"""Logs and returns the HTML source of the current page or frame.
The ``loglevel`` argument defines the used log level. Valid log
levels are ``WARN``, ``INFO`` (default), ``DEBUG``, and ``NONE``
(no logging).
levels are ``WARN``, ``INFO`` (default), ``DEBUG``, ``TRACE``
and ``NONE`` (no logging).
"""
source = self.get_source()
self.log(source, loglevel)
Expand Down
20 changes: 10 additions & 10 deletions src/SeleniumLibrary/keywords/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def element_should_not_contain(self, locator, expected, message=None, ignore_cas
% (locator, expected_before))

@keyword
def page_should_contain(self, text, loglevel='INFO'):
def page_should_contain(self, text, loglevel='TRACE'):
"""Verifies that current page contains ``text``.
If this keyword fails, it automatically logs the page source
Expand All @@ -126,7 +126,7 @@ def page_should_contain(self, text, loglevel='INFO'):

@keyword
def page_should_contain_element(self, locator, message=None,
loglevel='INFO', limit=None):
loglevel='TRACE', limit=None):
"""Verifies that element ``locator`` is found on the current page.
See the `Locating elements` section for details about the locator
Expand Down Expand Up @@ -167,7 +167,7 @@ def page_should_contain_element(self, locator, message=None,
raise AssertionError(message)

@keyword
def locator_should_match_x_times(self, locator, x, message=None, loglevel='INFO'):
def locator_should_match_x_times(self, locator, x, message=None, loglevel='TRACE'):
"""Deprecated, use `Page Should Contain Element` with ``limit`` argument instead."""
count = len(self.find_elements(locator))
x = int(x)
Expand All @@ -182,7 +182,7 @@ def locator_should_match_x_times(self, locator, x, message=None, loglevel='INFO'
% (count, locator))

@keyword
def page_should_not_contain(self, text, loglevel='INFO'):
def page_should_not_contain(self, text, loglevel='TRACE'):
"""Verifies the current page does not contain ``text``.
See `Page Should Contain` for explanation about the ``loglevel``
Expand All @@ -195,7 +195,7 @@ def page_should_not_contain(self, text, loglevel='INFO'):
self.info("Current page does not contain text '%s'." % text)

@keyword
def page_should_not_contain_element(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_element(self, locator, message=None, loglevel='TRACE'):
"""Verifies that element ``locator`` is found on the current page.
See the `Locating elements` section for details about the locator
Expand Down Expand Up @@ -865,7 +865,7 @@ def mouse_down_on_link(self, locator):
action.click_and_hold(element).perform()

@keyword
def page_should_contain_link(self, locator, message=None, loglevel='INFO'):
def page_should_contain_link(self, locator, message=None, loglevel='TRACE'):
"""Verifies link identified by ``locator`` is found from current page.
See the `Locating elements` section for details about the locator
Expand All @@ -878,7 +878,7 @@ def page_should_contain_link(self, locator, message=None, loglevel='INFO'):
self.assert_page_contains(locator, 'link', message, loglevel)

@keyword
def page_should_not_contain_link(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_link(self, locator, message=None, loglevel='TRACE'):
"""Verifies link identified by ``locator`` is not found from current page.
See the `Locating elements` section for details about the locator
Expand Down Expand Up @@ -918,7 +918,7 @@ def mouse_down_on_image(self, locator):
action.click_and_hold(element).perform()

@keyword
def page_should_contain_image(self, locator, message=None, loglevel='INFO'):
def page_should_contain_image(self, locator, message=None, loglevel='TRACE'):
"""Verifies image identified by ``locator`` is found from current page.
See the `Locating elements` section for details about the locator
Expand All @@ -931,7 +931,7 @@ def page_should_contain_image(self, locator, message=None, loglevel='INFO'):
self.assert_page_contains(locator, 'image', message, loglevel)

@keyword
def page_should_not_contain_image(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_image(self, locator, message=None, loglevel='TRACE'):
"""Verifies image identified by ``locator`` is found from current page.
See the `Locating elements` section for details about the locator
Expand All @@ -950,7 +950,7 @@ def get_matching_xpath_count(self, xpath, return_str=True):
return str(count) if is_truthy(return_str) else count

@keyword
def xpath_should_match_x_times(self, xpath, x, message=None, loglevel='INFO'):
def xpath_should_match_x_times(self, xpath, x, message=None, loglevel='TRACE'):
"""*DEPRECATED in SeleniumLibrary 3.2.* Use `Page Should Contain Element` with ``limit`` argument instead."""
self.locator_should_match_x_times('xpath:'+xpath, x, message, loglevel)

Expand Down
16 changes: 8 additions & 8 deletions src/SeleniumLibrary/keywords/formelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def checkbox_should_not_be_selected(self, locator):
"selected." % locator)

@keyword
def page_should_contain_checkbox(self, locator, message=None, loglevel='INFO'):
def page_should_contain_checkbox(self, locator, message=None, loglevel='TRACE'):
"""Verifies checkbox ``locator`` is found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand All @@ -77,7 +77,7 @@ def page_should_contain_checkbox(self, locator, message=None, loglevel='INFO'):
self.assert_page_contains(locator, 'checkbox', message, loglevel)

@keyword
def page_should_not_contain_checkbox(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_checkbox(self, locator, message=None, loglevel='TRACE'):
"""Verifies checkbox ``locator`` is not found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand Down Expand Up @@ -117,7 +117,7 @@ def unselect_checkbox(self, locator):
element.click()

@keyword
def page_should_contain_radio_button(self, locator, message=None, loglevel='INFO'):
def page_should_contain_radio_button(self, locator, message=None, loglevel='TRACE'):
"""Verifies radio button ``locator`` is found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand All @@ -130,7 +130,7 @@ def page_should_contain_radio_button(self, locator, message=None, loglevel='INFO
self.assert_page_contains(locator, 'radio button', message, loglevel)

@keyword
def page_should_not_contain_radio_button(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_radio_button(self, locator, message=None, loglevel='TRACE'):
"""Verifies radio button ``locator`` is not found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand Down Expand Up @@ -248,7 +248,7 @@ def input_text(self, locator, text):
self._input_text_into_text_field(locator, text)

@keyword
def page_should_contain_textfield(self, locator, message=None, loglevel='INFO'):
def page_should_contain_textfield(self, locator, message=None, loglevel='TRACE'):
"""Verifies text field ``locator`` is found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand All @@ -260,7 +260,7 @@ def page_should_contain_textfield(self, locator, message=None, loglevel='INFO'):
self.assert_page_contains(locator, 'text field', message, loglevel)

@keyword
def page_should_not_contain_textfield(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_textfield(self, locator, message=None, loglevel='TRACE'):
"""Verifies text field ``locator`` is not found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand Down Expand Up @@ -354,7 +354,7 @@ def click_button(self, locator):
element.click()

@keyword
def page_should_contain_button(self, locator, message=None, loglevel='INFO'):
def page_should_contain_button(self, locator, message=None, loglevel='TRACE'):
"""Verifies button ``locator`` is found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand All @@ -370,7 +370,7 @@ def page_should_contain_button(self, locator, message=None, loglevel='INFO'):
self.assert_page_contains(locator, 'button', message, loglevel)

@keyword
def page_should_not_contain_button(self, locator, message=None, loglevel='INFO'):
def page_should_not_contain_button(self, locator, message=None, loglevel='TRACE'):
"""Verifies button ``locator`` is not found from current page.
See `Page Should Contain Element` for explanation about ``message``
Expand Down
Loading

0 comments on commit ed9498d

Please sign in to comment.