0
votes

I am working on a program that can type something in the instagram search bar. Here is the code of the website:

<input class="XTCLo x3qfX " placeholder="Rechercher" value="" type="text">

I have already seen some posts about that but they did not work with me. Here is my code:

input_search = wait(browser, 10).until(
EC.visibility_of_element_located(
    (By.XPATH, "//input[@placeholder='Rechercher']")
))
action=ActionChains(browser)
action.move_to_element(input_search)
action.send_keys(search)
action.click()
action.perform()

how can I correct that ?

1
Please elaborate did not work? Error?? Stack trace??? - DebanjanB
Here is the error :selenium.common.exceptions.TimeoutException: Message: - user9886249
TimeoutException is the outcome of failed expected-conditions. Debug your code through find_element_by_* inconjunction with time.sleep(). If you are able to locate the element, update the question with the observations. - DebanjanB
Can you update the question with the relevant HTML? - DebanjanB
Done could you help me to solve the problem please ? - user9886249

1 Answers

0
votes

Please don't search by placeholder text as it will change with the browser language. You should use the locator which will be consistent across all the browser languages.

In your scenario if the browser language is English then placeholder text will be "Search".

I have modified your code.

Code Snippet:

input_search = wait(browser, 20).until(EC.visibility_of_element_located((By.XPATH, "//input[contains(@class,'XTCLo')]")))
input_search.click()
input_search.send_keys("search")