'Running functions depend on return from previous function Python Selenium
I have a test, that checks an element on a page: if element A is presented, test(function) returns A and runs another function A. If element B is presented, test(function) returns B and runs another function B. How can I do it in Python? I think of using dictionary and something like "if" expression, but I hardly imagine, how to do it. Thanks in advance! I don't have exact code, just something like this :/
from Pages import SearchHelper
def finding_pop(browser):
pop_click = SearchHelper(browser)
pop_click.go_to_site()
#element = finding_element_function.get_text()
return element
if element =='A':
#function test_A_click must be run
else:
#function test_B_click must be run
def test_A_click(browser):
pop_click = SearchHelper(browser)
pop_click.go_to_site()
logs = pop_click.setting_logs_raw('performance')
result = pop_click.for_logs(pop_click.log_filter, logs)
binded = pop_click.searching_params_in_logs_pops(result, 'bind_to')
ignored = pop_click.searching_params_in_logs_pops(result, 'ignore_to')
if binded == None and ignored == None:
handles, url, url1 = pop_click.opened_in_new_window()
assert handles > 1
assert url != url1
def test_B_click(browser):
pop_click = SearchHelper(browser)
pop_click.go_to_site()
logs = pop_click.setting_logs_raw('performance')
result = pop_click.for_logs(pop_click.log_filter, logs)
binded = pop_click.searching_params_in_logs_pops(result, 'bind_to')
ignored = pop_click.searching_params_in_logs_pops(result, 'ignore_to')
if binded == None and ignored == None:
handles, url, url1 = pop_click.opened_in_current_window()
print(url, url1)
assert handles > 1
assert url != url1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
