2017-02-16 65 views
0

我正在学习关于firefox中的seleniumIDE。seleniumIDE xpath选择器

我正在尝试打开“www.google.de”,然后点击“google suche”按钮。我在Firefox中使用了x-path add-on来获取x-path选择器,并获取相应按钮的值。

id('tsf')/x:div[2]/x:div[3]/x:center/x:input[1]。 只是为了学习,我强迫使用上面的X路径选择器。

我运行seleniumIDE,我想看看生成的xpath是否可以被seleniumIDE解析。因此,我使用的命令一下,并把下面的目标google.de上的基本URL

xpath=//div[@id='tsf']/div[2]/div[3]/center/input[1] 

,我得到的日志是

[info] Executing: |click | xpath=//div[@id='tsf']/div[2]/div[3]/center/input[1] | id('tsf')/x:div[2]/x:div[3]/x:center/x:input[1] | 
[error] Element xpath=//div[@id='tsf']/div[2]/div[3]/center/input[1] not found 

如果我插入的XPath = // DIV [2 ]/div [3]/center/input [1],在硒硒测试中通过。我认为div [@ id ='tsf']应该是整个独特xpath选择器的一部分,然而显然我不能正确理解这一点。

如何解决上述情况?

回答

0

'tsf'是表单的id,而不是div。

xpath=//form[@id='tsf']/div[2]/div[3]/center/input[1] 

或者更精确地说:

xpath=//form[@id='tsf']/div[@class='tsf-p']/div[@class='jsb']/center/input[1] 

退房FirePath XPath的帮助,使用的是Firefox时。

0

您可以简单地使用目标input元素的属性之一:

xpath=//input[@value="Google-Suche"]