Wednesday, 15 August 2012

java - How to identify an element in selenium even if xpath is same -



java - How to identify an element in selenium even if xpath is same -

i new selenium , trying autoamte web application in junit framework. many problem in identifying web elements,i stuck @ point 2 submit buttons having same xpath , css selector.

the difference can observe is.. in 2 form tags, can see classname different(for first form tag "feature_space_checkbox" , sec form tag "auto_fs_steps_checkbox")

as, need identify sec submit button..so tried identify sec submit button below

driver.findelement(new bychained(by.classname("auto_fs_steps_checkbox"),by.xpath("//*[@id='edit_brochure_2863']/input[3]")));

when seek execute this, got error as

org.openqa.selenium.nosuchelementexception: cannot locate element using by.chained({by.classname: auto_fs_steps_checkbox,by.xpath: //*[@id='edit_brochure_2863']/input[3]})

can please right me made mistake

adding dom scenario

<form action="/brochures/2865/feature_space_checked" class="feature_space_checkbox" id="edit_brochure_2865" method="post"><div style="margin:0;padding:0"> <input name="commit" type="submit" value="submit"> </form>

for sec submit button is..

<form action="/brochures/2865/update_auto_fs_steps" class="auto_fs_steps_checkbox" id="edit_brochure_2865" method="post"><div style="margin:0;padding:0"> <input name="commit" type="submit" value="submit"> </form>

firstly, xpath , css selectors not definitive. there many xpath , css every element on page have same xpath , css selectors incorrect.

for example, there need utilize xpath or combine 2 selectors?

the next css work;

form.auto_fs_steps_checkbox input

java html selenium xpath

No comments:

Post a Comment