您好,此代码的编写方式正确吗?当=='None'时,我想要self.deeplink_url
,然后在下面进行整个代码。实际上,当字符串不同于“ None”时,它工作正常,但是当我将None放在表上时,不会发生send_keys
如果self.deeplink_url(with parameters) == 'None'
,我试图做:
但是结果还不够好。
def deeplink_select_from_drop_down(self):
if self.deeplink_url == 'None':
deep_link_field = self.find_element(Locators.deep_link_field_fs_banner)
deep_link_field.click()
visibility_of_element_wait_xpath(self.context.driver, Locators.deep_link_drop_down_list, 10)
first_argument_on_deep_link_drop_down = self.find_element('//span[text()="Shop"]')
features.generic.java_script_scroll_to_view(self, first_argument_on_deep_link_drop_down)
features.generic.java_script_click(self, first_argument_on_deep_link_drop_down)
def deeplink_url(self, deep_link, locator):
"""enter deep link on deep_link empty input
:param deep_link:
:param locator:
:return:
"""
deep_link_url_input = self.find_element(locator)
if deep_link == 'None':
pass
else:
deep_link_url_input.send_keys(deep_link)
```
```
And from the drop down select first deep_link
And input "<deeplink_url>" as a deep link
```
```
Examples:|deeplink_url|
| None |
```
I want to use that logic when None is in examples do the drop_down_select_first deep_link method but when I pass some other string(different than 'None') like www.google.com pass that string:
this code working, but when deeplink_url == some string different than None thus string is also dispalyed in log and report and this destroys my concept
it just passes every parameter and I want to do it more generically
```
def deeplink_select_from_drop_down(self, deeplink_url):
if deeplink_url == 'None':
deep_link_field = self.find_element(Locators.deep_link_field_fs_banner)
deep_link_field.click()
visibility_of_element_wait_xpath(self.context.driver, Locators.deep_link_drop_down_list, 10)
first_argument_on_deep_link_drop_down = self.find_element('//span[text()="Shop"]')
features.generic.java_script_scroll_to_view(self, first_argument_on_deep_link_drop_down)
features.generic.java_script_click(self, first_argument_on_deep_link_drop_down)
def deeplink_url(self, deep_link, locator):
"""enter deep link on deep_link empty input
:param deep_link:
:param locator:
:return:
"""
deep_link_url_input = self.find_element(locator)
if deep_link == 'None':
pass
else:
deep_link_url_input.send_keys(deep_link)