当前位置: 首页 > 知识库问答 >
问题:

Selenium Python等待文本出现在元素错误显示中需要3个参数2

华宇
2023-03-14
Traceback (most recent call last):
  File "E:\test_runners 2 edit project\selenium_regression_test_5_1_1\Regression_TestCase\RegressionProjectEdit_TestCase.py", line 2714, in test_000057_run_clean_and_match_process
    process_lists_page.wait_for_run_process_to_finish()
  File "E:\test_runners 2 edit project\selenium_regression_test_5_1_1\Pages\operations.py", line 334, in wait_for_run_process_to_finish
    EC.text_to_be_present_in_element("No data to display"))
TypeError: __init__() takes exactly 3 arguments (2 given)
def wait_for_run_process_to_finish(self): # When the process is running use WebdriverWait to check until the process has finished.  No data to display is shown when process has completed.
    try:
        WebDriverWait(self.driver, 900).until(
            EC.text_to_be_present_in_element("No data to display"))
        no_data_to_display_element = self.get_element(By.ID, 'operations_monitoring_tab_current_ct_fields_no_data')
        print "no_data_to_display_element ="
        print no_data_to_display_element.text
        if no_data_to_display_element.text == "No data to display":
            return True
    except NoSuchElementException, e:
        print "Element not found "
        print e
        self.save_screenshot("wait_for_run_process_to_finish")
WebDriverWait(self.driver, 900).until(
            EC.text_to_be_present_in_element(By.ID, 'operations_monitoring_tab_current_ct_fields_no_data', "No data to display"))

错误显示:typeError:init()正好接受3个参数(给定4个)

共有1个答案

孔永年
2023-03-14
class selenium.webdriver.support.expected_conditions.text_to_be_present_in_element(locator, text_)
EC.text_to_be_present_in_element((By.ID, "operations_monitoring_tab_current_ct_fields_no_data"), "No data to display")
 类似资料:
  • 我正在使用Android Espresso Web测试Android应用程序中的Web视图。它需要一些时间来完成与加载网站。在对元素执行单击操作之前,我需要等待它显示出来。我能用什么API吗?我不想使用sleep()方法。

  • 在以下网站上:https://hepa.hu/hirek我正在等待这篇文章出现。这是javascript生成的,所以我开始在C#中使用Selenium。我编写了以下代码,以等待元素出现: (Xpath是从节点本身复制的)代码是有效的,就它真正等待元素出现而言,但是当我尝试访问里面的文本(firstResult. Text)时,它只是给出“”,而不是里面的实际文本。文本在h3标签内。我也一直在使用H

  • 现在,如果传入false作为第三个参数,仍然会看到一个错误。理想情况下,我希望一个函数等待一个元素,如果它没有找到该元素就返回。

  • 问题内容: 是否有办法让a 等待许多元素之一出现并根据哪个元素出现而采取相应的行动? 目前,我在try循环中执行了一个操作,如果发生超时异常,我将运行备用代码,等待其他元素出现。这看起来很笨拙。有没有更好的办法?这是我的(笨拙的)代码: 它需要等待整整10秒钟,然后才能查看系统上是否已存在该文件的消息。 该函数仅执行许多调用,如下所示: 有人有任何建议以更有效的方式完成此任务吗? 问题答案: 创建

  • 问题内容: 单击特定按钮时-我的测试站点将打开模式窗口。 但是模式窗口的打开是不同的 两者都有不同的标题,不同的选项和不同的位置。现在我应该等到模态。 是否可以等到任一模态窗口(WebElement)可见? 我已经在WebDriverWait方法中进行搜索,但是所有方法都必须等到特定WebElement可见或可单击为止。 我找不到更好的方法来等到任何一个都可见。 您能提出一种解决这种情况的方法吗?

  • 问题内容: 单击特定按钮时-我的测试站点将打开模式窗口。 但是模式窗口的打开是不同的 两者都有不同的标题,不同的选项和不同的位置。现在我应该等到模态。 是否可以等到任一模态窗口(WebElement)可见? 我已经在WebDriverWait方法中进行搜索,但是所有方法都必须等到特定的WebElement可见或可单击为止。 我找不到更好的方法来等到任何一个都可见。 您能提出一种解决这种情况的方法吗