java - Selenium WebDriver set Attribute having webelement -
currently have problem - want switch out of current frame parent. application have lot of of inner frames, using driver.switchto().defaultcontent() not case. in discussion possible solution suggested - should remember frames visited , and iterate on them top using
driver.switchto().defaultcontent()
the main problem in fact, in application i, sometimes, forced use switching frames located xpath , other locators - use switch webelement. , mentioned in discussion above after switching located webelement becomes invalid , can't used switching. should have way find element inside frame again. although can locate index of frame element executing js calls(i.e (webelement)executescript("window.frames[i]").equals(mywebelement)
), not case index may change when frames deleted page. either can try find frame names , id's may not specified.
so see possible solution - set attribute frames parent of selected - example attribute active value true. should able methods can switch frame (there exist 3). in methods can receive webelement representing frame, far know change attribute value should execute js code. problem how locate current webelement in js.
thanks reading all.
look @ code snippet above.that's best way can locate current element in js passing element argumet execute script , referring in js using arguments[0]
webelement element = driver.findelement(by.id("foo")); string contents = (string)((javascriptexecutor)driver).executescript("return arguments[0].innerhtml;", element);
Comments
Post a Comment