开发者

selenium: nested div element not found

I am kinda new to selenium and trying out test cases with testng with eclipse. The webpage i'm trying to open loads from multiple ajax calls. There are nested div's which load inside a table. one div element is a search box. When i'm trying to enter the search word using the test case it errors out 'element not found'. I tried开发者_运维知识库 out different ways of finding an element but in vain. I would really be thankful for ways to resolve this problem.

thanks, ~sharath


I suggest that you use XPath and then finding an input box will be as simple as submitting this query to the find_element_by_xpath method: "//input(@name='name')"

Refer to W3school for complete syntax specification.

You could use some tools to test xpath, e.g.: Firebug.

I wrote an entry on my blog for this purpose.


Without knowing the structure of your page etc it's a little difficult to know exactly what's happening.

One thing I can sugest is that you do a wait for the element you require, before trying to do something with it.

For example, you may add a waitForElementPresent command before trying to click into something such as a text box.

Consider:

<input type="text" id="mySearchBox" />

Ideally you'll want to have 2 commands:

waitForelementPresent : id=mySearchBox

and then

type : id=mySearchBox : Text To Search On

These kinds of things rarely seem to be included as part of the initial recording process. I often have to go in and specifically tell Selenium to wait for certain elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜