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
• 720 points
100 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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
• 820 points

Related Questions In Selenium

0 votes
3 answers
0 votes
1 answer
+2 votes
2 answers

How can I press ENTER key with the execute_script in selenium python?

The below code containing Keys.ENTER might just ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,030 points
4,020 views
0 votes
1 answer

How to use Selenium with Python?

There are many resources for selenium - ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,030 points
121 views
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,030 points
75 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
448 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
56 views
0 votes
1 answer
0 votes
1 answer

What is the problem with the Alert function in the Selenium IDE

To simulate the button OK and click ...READ MORE

answered Mar 5 in Selenium by Surya
• 820 points
65 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.