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 9, 2019 in Selenium by Vaishnavi
• 1,180 points
6,176 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 9, 2019 by Surya
• 970 points
how can I press 'Enter' after I typed the search?
You could implement "Enter" using send_keys(Keys.ENTER)

Related Questions In Selenium

0 votes
3 answers

How to click the search button using Selenium web driver and Python

You can try with tag. #this code will ...READ MORE

answered Apr 10, 2019 in Selenium by Matin
16,286 views
0 votes
1 answer

Is it possible to automate the captcha and bar-code reader using Selenium?

Hey Ruhi, it’s not possible to automate ...READ MORE

answered Jun 4, 2019 in Selenium by Umang
2,446 views
0 votes
1 answer
0 votes
0 answers
0 votes
2 answers

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,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
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,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,902 views
0 votes
1 answer

How to check if an image is displayed on web page while working with Selenium WebDriver?

I've come across a similar situation before, where the image ...READ MORE

answered May 10, 2019 in Selenium by Surya
• 970 points
7,963 views
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 14, 2019 in Selenium by Surya
• 970 points
4,770 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP