How can I search for a video on YouTube

0 votes
Can someone explain me the way to search a video on Youtube?
Dec 20, 2018 in Selenium by Jino
• 5,810 points
5,780 views

1 answer to this question.

0 votes

I will tell you step by step as how to do this, please follow the steps and you are good to go.

1. set the path of your chrome/ firefox driver you are going to use.

System.setProperty("webdriver.chrome.driver","C:\\Your\\Path\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

2. Open the youtube webpage 

driver.get("https://www.youtube.com");

3. Get the id for the search box and type the keyword.

driver.findElement(By.id("search")).sendKeys("Happiness");

4. Click on the search key.

driver.findElement(By.id("search-icon-legacy")).click();

Hope this helps!

answered Dec 20, 2018 by Nabrupa
not working,navigating till opening youtube
Are you getting any error in the process?
That is because there many be more than one id with name "search". i too faced similar prob.

Try this, it is working.

driver.findElement(By.name("search_query")).sendKeys("Selenium");

driver.findElement(By.id("search-icon-legacy")).click();

Related Questions In Selenium

0 votes
1 answer

How can I automate google search for a keyword using ruby selenium webdriver?

Hi Amir, following code snippet shows how ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
1,416 views
0 votes
1 answer

How do I play a thumbnail video for a particular product eg. mobile on flipkart site?

Automating video streaming is a bit challenging ...READ MORE

answered Jul 28, 2020 in Selenium by Sirajul
• 59,230 points
856 views
+1 vote
1 answer
0 votes
1 answer

How to write a code for combo box and how can i select a country from country dropdown?

https://stackoverflow.com/questions/40017443/how-to-perform-dropdow ...READ MORE

answered May 8, 2020 in Selenium by vaibhav
1,310 views
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
12,619 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
8,572 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
6,629 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,519 views
–1 vote
1 answer
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