-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WithX identifiers can be used with With.locator() call.
- Loading branch information
1 parent
eeec865
commit 5ea010b
Showing
11 changed files
with
132 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
nav_link4: | ||
nav_link: | ||
wtype: xpath | ||
value: "//li[contains(*//text(), '{lname}')]" |
37 changes: 37 additions & 0 deletions
37
arjuna-samples/arjex_with_adv/test/module/check_02_withx_using_with.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
''' | ||
This file is a part of Arjuna | ||
Copyright 2015-2020 Rahul Verma | ||
Website: www.RahulVerma.net | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
''' | ||
|
||
from arjuna import * | ||
from arjex_with_adv.lib.gom.app import WordPress | ||
|
||
@for_test | ||
def dashboard(request): | ||
# Setup | ||
wordpress = WordPress() | ||
home = wordpress.launch() | ||
dashboard = home.login_with_default_creds() | ||
yield dashboard | ||
|
||
# Teadown | ||
dashboard.top_nav.logout() | ||
wordpress.quit() | ||
|
||
@test | ||
def check_withx_using_with(request, dashboard): | ||
dashboard.left_nav.element(With.nav_link(lname="Media")).click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from arjuna.core.adv.types import CIStringDict | ||
from arjuna.configure.impl.validator import Validator | ||
|
||
class WithX: | ||
|
||
def __init__(self, xdict={}): | ||
self.__xdict = CIStringDict() | ||
for k,v in xdict.items(): | ||
try: | ||
self.__xdict[Validator.arjuna_name(k)] = {"wtype" : xdict[k]["wtype"].strip().upper(), "value" : xdict[k]["value"].strip()} | ||
except Exception as e: | ||
print(e) | ||
print(xdict) | ||
raise Exception(f"Invalid WithX name >>{k}<<.") | ||
|
||
def has_locator(self, name): | ||
return name in self.__xdict | ||
|
||
def format_args(self, name, *vargs, **kwargs): | ||
if not self.has_locator(name): | ||
raise Exception("No WithX locator with name {} found.".format(name)) | ||
fmt = self.__xdict[name] | ||
try: | ||
return fmt["wtype"], fmt["value"].format(*vargs, **kwargs) | ||
except Exception as e: | ||
from arjuna import Arjuna | ||
Arjuna.get_logger().error(f"Error in processing withx {name} : {fmt} for vargs {vargs} and kwargs {kwargs}") | ||
raise | ||
|
||
def format(self, name, loc_obj): | ||
vargs = None | ||
kwargs = None | ||
if type(loc_obj) is str: | ||
vargs = [loc_obj] | ||
kwargs = dict() | ||
elif type(loc_obj) in {list, tuple}: | ||
vargs = loc_obj | ||
kwargs = dict() | ||
elif type(loc_obj) is dict: | ||
vargs = [] | ||
kwargs = loc_obj | ||
return self.format_args(name, *vargs, **kwargs) | ||
|
||
|
||
|
Oops, something went wrong.