How can I search for a video on YouTube

0 votes
Can someone explain me the way to search a video on Youtube?
Dec 19, 2018 in Selenium by Jino
• 5,810 points
2,435 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 19, 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
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
• 58,950 points
150 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
550 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,520 points
4,330 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,010 points
5,253 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,890 points
3,135 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 2, 2020 in Selenium by Sri
• 3,010 points
3,640 views
–1 vote
1 answer