I am using WebdriverWait to wait for some text to be present in an element on a webpage. I am using Selenium with Python. My syntax is not correct. I am getting the error: TypeError: init() takes exactly 3 arguments (2 given):
Error trace:
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)
My code snippet is:
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")
The scenario is the user clicks the run button and it starts of a process. When the process completes the text "No data to display" will be shown. I would like to wait until this text is displayed then I know the process has completed. Before I was using time.sleep(900) which is not good as it explicitly waits the full 15 mins. The process could complete in 8 mins, sometimes 12 mins.
I have also tried:
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"))
The error shows: TypeError: init() takes exactly 3 arguments (4 given)
What is the correct syntax to wait for the text to be present? Thanks, Riaz