小编use*_*859的帖子

如何鼠标悬停并单击webdriver中的元素

我需要将鼠标悬停在一个元素上,但我无法将鼠标悬停在它上面。首先我需要将鼠标悬停在一个元素上,然后我需要选择另一个元素。我需要将鼠标悬停在一个元素上,但我无法将鼠标悬停在它上面。首先我需要将鼠标悬停在一个元素上,然后我需要选择另一个元素。我需要将鼠标悬停在一个元素上,但我无法将鼠标悬停在它上面。首先我需要将鼠标悬停在一个元素上,然后我需要选择另一个元素。我需要将鼠标悬停在一个元素上,但我无法将鼠标悬停在它上面。首先我需要将鼠标悬停在一个元素上,然后我需要选择另一个元素。包 nxusdata;

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;

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.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class MouseHoveringworpress {
    public static WebDriver driver;

    @BeforeTest
    public void openinBrowser(){


        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
         driver = new ChromeDriver();
        driver.get("https://wordpress.com/wp-login.php?redirect_to=https%3A%2F%2Fwordpress.com%2F");

        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    }



    @Test
    public void menus() throws InterruptedException{

        driver.findElement(By.xpath("//*[@id='user_login']")).sendKeys("ritu7180");
        driver.findElement(By.xpath("//*[@id='user_pass']")).sendKeys("jaiguruji123");
        driver.findElement(By.xpath("//*[@id='wp-submit']")).click();
        //*[@id='header']/a[2]/span


        Thread.sleep(15000);
        driver.findElement(By.xpath("//*[@id='header']/a[1]/span")).click();




        //*[@id='secondary']/div/ul/li[4]/ul/li[5]/a/span[1]
        Thread.sleep(4000);


        driver.findElement(By.xpath("//*[@id='secondary']/div/ul/li[4]/ul/li[5]/a/span[1]")).click();
        Thread.sleep(10000);
        Set <String> windows =driver.getWindowHandles();
        System.out.println(windows.size());
        //Print the size of windows
        Iterator<String> it = windows.iterator();
        //iterate through your …
Run Code Online (Sandbox Code Playgroud)

java selenium

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

selenium ×1