【发布时间】:2023-03-10 13:07:01
【问题描述】:
enter image description here无法使用 selenium webdriver 点击内联元素。
除了图片链接(右上角),还有一个方形图标。需要单击该图标并选择地图。 附上截图。 我使用了 xpath、cssselector、ID、名称,但没有任何效果。 谁能帮我解决这个问题。
代码:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class webelements2 {
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.gecko.driver","C:\\Users\\rpremala003\\Downloads\\geckodriver-v0.14.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.manage().window().maximize();
driver.findElement(By.id("gbwa")).click();
driver.findElement(By.className("gb_3")).click();
}
}
【问题讨论】:
标签: selenium selenium-webdriver