Skip to content

Commit a1ff568

Browse files
authored
[qacode] fix for issue #305 (#306)
* [qacode] fix for issue #305 * [qacode] fix flake * [qacode] fix docs env for tox * [qacode] fix CIs * [qacode] fix appveyor * [qacode] appveyor, please... i need you * [qacode] windows, i hate you, sometimes
1 parent 9d3918e commit a1ff568

21 files changed

+25
-588
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
name: Before Tests
3737
command: |
3838
./cc-test-reporter before-build
39+
touch logs/qacode.log
3940
4041
- run:
4142
name: Run Tests

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ install:
2929
- pip install tox
3030
- python setup.py clean build install sdist
3131
script:
32+
- touch logs/qacode.log
3233
- tox -e "flake8"
3334
- tox -e "$TOXENV"
3435
- pip freeze

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515

1616
### Removed
1717

18+
- [BP] remove ControlForm and StrictRules + tests #305
19+
1820

1921
## [v0.6.3] - 2020-01-29
2022

USAGE.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,6 @@ Example of usage
145145
txt_password.type_text('SuperSecretPassword!', clear=True)
146146
btn_login.click()
147147
148-
149-
150-
ControlForm
151-
~~~~~~~~~~~
152-
153-
+ Param **rules** : Allow to add strict_rules configuration to laod StrictRule class for each rule ( example: ``strict_rule = StrictRule('my_named_rule', StrictType.TAG, StrictSeverity.HIGHT)`` )
154-
155-
- Methods for **ControlForm**
156-
157-
+ method **__load__** : Load properties from settings dict. Some elements need to search False to be search at future
158-
+ method **__settings_parse__** : Allow to parse settings obtaining from super and applying self instance behaviour
159-
+ method **__rules_parse__** : Validate rules for each type of StricRule
160-
+ method **__rules_apply__** : Allow to apply rules using self WebElement
161-
+ method **__rules_apply_tag__** : Apply Tag based on StictType.TAG enum
162-
+ method **__check_reload__** : Allow to check before methods calls to ensure if it's neccessary reload element properties
163-
+ method **reload** : Reload 'self.settings' property:dict and call to instance logic with new configuration
164-
165-
- Properties for **ControlForm**
166-
167-
+ property **rules** : `GET`
168-
169148
ControlDropdown
170149
~~~~~~~~~~~~~~~
171150

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ install:
6565
- "pip install tox"
6666

6767
test_script:
68+
- "echo hello > logs\\qacode.log"
6869
- "tox -e flake8"
6970
- "tox -e %TOXENV%"
7071

logs/qacode.log

Whitespace-only changes.

qacode/core/webs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from qacode.core.webs import html_attrs
88
from qacode.core.webs import html_tags
99
from qacode.core.webs import pages
10-
from qacode.core.webs import strict_rules
1110

1211

1312
__all__ = [
@@ -16,5 +15,4 @@
1615
'html_attrs',
1716
'html_tags',
1817
'pages',
19-
'strict_rules'
2018
]

qacode/core/webs/controls/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
from qacode.core.webs.controls import control_base
66
from qacode.core.webs.controls import control_dropdown
7-
from qacode.core.webs.controls import control_form
87
from qacode.core.webs.controls import control_table
98

109

1110
__all__ = [
12-
'control_base', 'control_dropdown', 'control_form', 'control_table']
11+
'control_base', 'control_dropdown', 'control_table']

qacode/core/webs/controls/control_base.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def __init__(self, bot, **kwargs):
4040
self._on_instance_search = None
4141
self._auto_reload = None
4242
# __search__, step 2
43-
self._tag = None
4443
self._text = None
4544
self._is_displayed = None
4645
self._is_enabled = None
@@ -127,7 +126,6 @@ def __search__(self):
127126
self.bot.log.debug(MSG.CB_SEARCH_FOUND)
128127
# Step 2 load minimal properties defined by qacode
129128
self.bot.log.debug(MSG.CB_PROP_LOADING)
130-
self._tag = self.get_tag()
131129
self._text = self.get_text()
132130
self._is_displayed = nav.ele_is_displayed(self.element)
133131
self._is_enabled = nav.ele_is_enabled(self.element)
@@ -200,15 +198,6 @@ def find_children(self, selector, locator=By.CSS_SELECTOR):
200198
self.bot.log.debug(MSG.CB_FINDCHILD_LOADED)
201199
return ctls
202200

203-
def get_tag(self):
204-
"""Returns tag_name from Webelement"""
205-
self.bot.log.debug(MSG.CB_GETTAG_LOADING)
206-
self.__check_reload__()
207-
tag = self.bot.navigation.ele_tag(self.element)
208-
self.bot.log.debug(MSG.CB_GETTAG_LOADED.format(tag))
209-
self._tag = tag
210-
return tag
211-
212201
def type_text(self, text, clear=False):
213202
"""Type text on input element
214203
@@ -418,14 +407,13 @@ def __repr__(self):
418407
return ("{}: name={}, "
419408
"bot.browser={}, bot.mode={} \n"
420409
"settings={} \n"
421-
"tag={}, is_displayed={}, "
410+
"is_displayed={}, "
422411
"is_enabled={}, is_selected={}").format(
423412
self.__class__.__name__,
424413
self.name,
425414
self.bot.settings.get('browser'),
426415
self.bot.settings.get('mode'),
427416
self.settings,
428-
self.tag,
429417
self.is_displayed,
430418
self.is_enabled,
431419
self.is_selected)
@@ -505,8 +493,12 @@ def auto_reload(self):
505493

506494
@property
507495
def tag(self):
508-
"""GET for _tag attribute"""
509-
return self._tag
496+
"""GET for _tag attribute. Returns from Webelement directly"""
497+
self.bot.log.debug(MSG.CB_GETTAG_LOADING)
498+
self.__check_reload__()
499+
tag = self.bot.navigation.ele_tag(self.element)
500+
self.bot.log.debug(MSG.CB_GETTAG_LOADED.format(tag))
501+
return tag
510502

511503
@property
512504
def text(self):

qacode/core/webs/controls/control_dropdown.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
# -*- coding: utf-8 -*-
2-
"""Package module qacode.core.webs.control_form"""
2+
"""Package module qacode.core.webs.control_dropdown"""
33

44

55
from qacode.core.exceptions.control_exception import ControlException
66
from qacode.core.loggers import logger_messages as MSG
7-
from qacode.core.webs.controls.control_form import ControlForm
7+
from qacode.core.webs.controls.control_base import ControlBase
88
from selenium.webdriver.support.ui import Select
99

1010

11-
class ControlDropdown(ControlForm):
11+
class ControlDropdown(ControlBase):
1212
"""TODO: doc class"""
1313

1414
def __init__(self, bot, **kwargs):
15-
"""Instance of ControlForm. Load properties from settings dict.
15+
"""Instance of ControlDropdown. Load properties from settings dict.
1616
Some elements need to search False to be search at future
1717
"""
18-
rules = kwargs.get("rules") or []
19-
if not bool(rules):
20-
rules.append(
21-
{"tag": "select", "type": "tag", "severity": "hight"})
22-
kwargs.update({"rules": rules})
2318
super(ControlDropdown, self).__init__(bot, **kwargs)
2419
self._dropdown = None
2520

2621
def __load__(self, **kwargs):
2722
"""Allow to reinstance control properties"""
2823
super(ControlDropdown, self).__load__(**kwargs)
29-
if self.tag is not None and self.tag != "select":
30-
self.bot.log.error(MSG.CDD_BADTAG)
31-
raise ControlException(MSG.CDD_BADTAG, info_bot=self._info_bot)
3224
if self._on_instance_search:
3325
self._dropdown = Select(self._element)
3426

0 commit comments

Comments
 (0)