-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyoutubeAPP.java
More file actions
39 lines (28 loc) · 1.24 KB
/
youtubeAPP.java
File metadata and controls
39 lines (28 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.github.bonigarcia.wdm.WebDriverManager;
public class youtubeAPP {
public static void main(String[] args) {
// Setup ChromeDriver
WebDriverManager.chromedriver().setup();
// Create an instance of ChromeDriver
WebDriver driver = new ChromeDriver();
// Maximize the browser window
driver.manage().window().maximize();
// Open YouTube
driver.get("https://www.youtube.com/");
// Wait for the Shorts icon to be clickable
WebDriverWait wait = new WebDriverWait(driver, 10);
// Updated XPath to locate the Shorts icon
WebElement shortsIcon = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//yt-icon[@icon='video-youtube-shorts']")));
// Click on the Shorts icon
shortsIcon.click();
// Optional: Perform other actions with the browser
// Close the browser
driver.quit();
}
}