Paulquappe
Paulquappe

Reputation: 144

selenium IDE and dynamic DOM elements

Hello overflowfellows,

actually iam on Testing website and my company wants me to use selenium IDE for automated testing on milestones.

My Question is about locating elements in dynamic wrappers, count and verify there presence. For instance, das this wrapper contains more tiles of this class name or this. or for instance, i have my slider wrapper and want to check fpr the presence of images in this.

consider the following xpath selector for the slider wrapper:

/html/body/div[1]/div[2]/section/main/div/div

in css selectors

html.header-visible.js.flexbox.flexboxlegacy.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths.wf-telegroteskfett-n4-active.wf-telegroteskhalbfett-n4-active.wf-telegroteskheadlineregular-n4-active.wf-telegroteskheadlineultra-n4-active.wf-telegrotesknormal-n4-active.wf-telegroteskultra-n4-active.wf-teleicon-n4-active.wf-telekomfussballicons-n4-active.wf-active.device-desktop body.loaded div.main div.controller.component section.component.controller.loaded.active main.col-xs-24.col-md-18 div.controller.component.clipping div.slider-wrapper.col-sm-24.col-md-16

and for the img in it, that comes dynamicaly: xpath

/html/body/div[1]/div[2]/section/main/div/div/div/div/div/div[2]/a/picture

cssselector

html.header-visible.js.flexbox.flexboxlegacy.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths.wf-telegroteskfett-n4-active.wf-telegroteskhalbfett-n4-active.wf-telegroteskheadlineregular-n4-active.wf-telegroteskheadlineultra-n4-active.wf-telegrotesknormal-n4-active.wf-telegroteskultra-n4-active.wf-teleicon-n4-active.wf-telekomfussballicons-n4-active.wf-active.device-desktop body.loaded div.main div.controller.component section.component.controller.loaded.active main.col-xs-24.col-md-18 div.controller.component.clipping div.slider-wrapper.col-sm-24.col-md-16 div.controller.component.clipping.slick-initialized.slick-slider div.slick-list.draggable div.slick-track div.slick-slide.slick-active a picture.component

please dont be mad with me, because i wall-of-text you.

to make this question reasonable.

how do i check for elements in elements using Selenium IDE.

I have some experience with selenium JAVA and here with loops and conditions i find it more easy to reach my selectors.

long story short: can i use selenium IDE in dynamic contexts to re-do my testcases.

any answer will be apriciated.

have a nice day with br from paulq

Upvotes: 0

Views: 781

Answers (1)

DMart
DMart

Reputation: 2461

Let me start by simplifying some of your xpath: /html/body/div[1]/div[2]/section/main/div/div becomes //section/main/div/div

/html/body/div[1]/div[2]/section/main/div/div/div/div/div/div[2]/a/picture becomes //section/main/div/div//a/picture

You could then use the verifyXpathCount if you have an exact count.

Or you can run some java script to use the amount of elements returned via Element.getElementsByTagName() where the element in question is the wrapper. That way you are only getting elements that are descendants of that element and not the entire document.

Upvotes: 1

Related Questions