1

so I am using HTML Unit to click an item on a webpage. I usually use Xpath to select my items, but this page gives every element a randomly generated ID and class. I usually use Google Chrome to get the Xpath of elements, but it gives me something like this: //*[@id=":og"] where :og is the randomly generated ID. I know that sometimes chrome gives me Xpath without any ID's or Classes, like this: /html/body/table/tbody/tr[2]/td/table/tbody/tr[3]/td/form/table[2]/tbody/tr/td/input[2] Is it possable to get an Xpath that does not rely on IDs or Classes in a case like this? Thanks.

4

1 回答 1

1

为了构建更短的 xpath 或仅基于标签的替代路径,您可以使用可以让您做到这一点的插件。我特别喜欢 Firefox 中的 Selenium IDE,但在 Chrome 中,您可以使用 Xpath Helper 之类的东西。您可以通过搜索 chrome 网上商店来探索其他内容。

于 2013-06-01T01:45:59.213 回答