user_val = WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.ID, "username")))
Why does EC.presence_of_element_located require two sets of parenthesis? I didn’t see the need for two pair so I removed one of them and the code quite working — I just flew by it like it was a comment. I added them back and it started working again. Just curious as to why it would require two sets?
>Solution :
user_val = WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.ID, "username")))
EC.presence_of_element_located is a method that takes a single argument, which is a tuple representing the locating strategy and the locator value. In this case, it’s (By.ID, "username").
WebDriverWait(browser, 30).until(...) is a method that takes a single argument, which is the expected condition to wait for.
Here, you are passing EC.presence_of_element_located((By.ID, "username")) as the expected condition.
Therefore, the double parentheses are necessary to encapsulate the arguments for both the presence_of_element_located method and the until method.
If you remove one set of parentheses, you are essentially passing the method itself (EC.presence_of_element_located) rather than calling it with the specified arguments, which leads to incorrect behavior.