gpt4 book ai didi

java - 如何 "hover over" Selenium 中的按钮?

转载 作者:行者123 更新时间:2023-11-29 07:00:18 25 4
gpt4 key购买 nike

<分区>

如何为元素添加悬停?考虑我的以下代码:

package AutomationFramework;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;

public class LoginPage {

private static WebDriver driver = null;

public static void main(String[] args) {

// Create a new instance of the Firefox driver

driver = new FirefoxDriver();

//Put a Implicit wait

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

//Launch the Website

driver.get("URL");

// Find the element that's ID attribute is 'account'(My Account)

// driver.findElement(By.xpath("/html/body/table/tbody/tr[5]/td/table/tbody/tr/td[2]/form/table/tbody/tr[3]/td[2]/input")).click();

// Enter Username on the element

driver.findElement(By.name("userName")).sendKeys("remote");

// Find the element that's ID attribute is 'pwd' (Password)

driver.findElement(By.name("password")).sendKeys("aaaaaa");

// Now submit the form. WebDriver will find the form for us from the element

driver.findElement(By.name("submit")).click();

// Print a Log In message to the screen

System.out.println(" Login Successfully");
driver.findElement(By.name("img2")).click();

// Find the element that's ID attribute is 'account_logout' (Log Out)

//driver.findElement (By.name("img104")).click();

// Close the driver

driver.quit();

}

}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com