Selenium 编程:允许您查看浏览器元素名称的快捷方式是什么

Selenium Programming: what is the short cut that allow you to see the element names for your browser

好的,所以你知道你想去 google.com,你想在搜索框中输入一些东西。

如何找出要在代码中使用的元素的名称? 有没有什么东西可以让你检查你正在使用的浏览器来查找元素名称? IE vs. Chrome vs. Firefox vs. Edge.

有什么不同吗
WebElement searchBox = driver.findElement(By.name("q"));

我在Java

编程

您可以通过单击 F12 或右键单击要查找的项目 -> 选择检查来打开浏览器检查器。你会得到这个

您要查找的元素将在屏幕中间突出显示。您也可以在 console 选项卡中检查您的选择器,如图中的 examole。