How to automate the Instagram search bar with selenium

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've already looked into a few posts about that but none of them 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 do I correct that?

Mar 8 in Selenium by Vaishnavi
• 1,160 points
618 views

1 answer to this question.

+1 vote

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

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

I have modified your code.

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")

Hope this helps! :)

answered Mar 8 by Surya
• 970 points

Related Questions In Selenium

0 votes
3 answers
0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
1,021 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,160 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
897 views
0 votes
1 answer
0 votes
1 answer

How to get the select options using Selenium WebDriver in Java

Hey there! You should be able to get ...READ MORE

answered Jun 13 in Selenium by Surya
• 970 points
155 views