AssertTrue 缺少 1 个必需的位置参数

北方人

我试图断言一个元素的存在,我可以让它工作,但现在我想要的方式。

我有一个通用的函数文件:-

from selenium.common.exceptions import NoSuchElementException


def is_element_present_common(self, how, what):
    try:
        self.driver.find_element(by=how, value=what)
    except NoSuchElementException as e:
        return False
    return True

...和我的主文件:-

import unittest
from Common import common_functions, initialisation, login
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.common.exceptions import NoSuchElementException


class QuickTestPlanLogin(unittest.TestCase):
    def setUp(self):
        self.driver = initialisation.start_webdriver()
        self.driver = initialisation.start_sap(self.driver)

    def tearDown(self):
        self.driver.close()

    def is_element_present(self, how, what):
        try:
            self.driver.find_element(by=how, value=what)
        except NoSuchElementException as e:
            return False
        return True

    def test_login(self):
        wait = initialisation.wait_for(self.driver)
        self.driver = login.default_login(self.driver, "username", "password")

        # self.assertTrue(self.is_element_present(By.ID, "my-projects-table_info"))
        # self.assertTrue(common_functions.is_element_present_common(By.ID, "my-projects-table_info"))

有两个断言语句。如果我运行第一个它工作正常,但它正在调用我不想要的 is_element_present 函数。我想从 common_functions 文件中调用 is_element_present_common 函数。每次运行第二个 assert 语句时,都会出现以下错误:-

TypeError: is_element_present() missing 1 required positional argument: 'what'

我知道我错过了一些非常简单的东西......

德班扬B

将函数定义更改为:

def is_element_present_common(how, what):

将调用更改is_element_present_common为:

self.assertTrue(common_functions.is_element_present_common(By.ID, "my-projects-table_info"))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ArrayField缺少1个必需的位置参数

__init __()缺少1个必需的位置参数

缺少1个必需的位置参数:“ pk”

缺少1个必需的位置参数:“键”

python缺少1个必需的位置参数

channel()缺少1个必需的位置参数

缺少1个必需的位置参数:“循环”

缺少 1 个必需的位置参数:“数字”

缺少1个必需的位置参数:'self'

缺少1个必需的位置参数:“ msg”

缺少1个必需的位置参数

缺少 1 个必需的位置参数 dt

函数缺少 1 个必需的位置参数

缺少 1 个必需的位置参数 [Telebot]

method1()缺少1个必需的位置参数:“ self”

__init__() 缺少 1 个必需的位置参数:'self'

类型错误:post() 缺少 1 个必需的位置参数

类型错误:readData() 缺少 1 个必需的位置参数:“数据”

TypeError:detail()缺少1个必需的位置参数:“ request”

TypeError:predict()缺少1个必需的位置参数:“ params”

多处理,缺少 1 个必需的位置参数:“响应”

setUpClass()缺少1个必需的位置参数:“ cls”

TypeError:fit()缺少1个必需的位置参数:'y'

load_model()缺少1个必需的位置参数:“ filepath”

TypeError:append()缺少1个必需的位置参数:“ values”

django 模板标签缺少 1 个必需的位置参数:值

geopy TypeError:geocode()缺少1个必需的位置参数:“ query”

TypeError:setDocumentLocator()缺少1个必需的位置参数:“ locator”

Django模型属性:缺少1个必需的位置参数: