java - Click on an image which changes dynamically -


i have set of images properties change every time web app executed. need click 1 of them in particular, can't identify uniquely.

here current code:

list <webelement> listofimages =driver.findelements(by.classname("thumb"));  (webelement image : listofimages) {     system.out.println("image: " + image.getattribute("src")); } 

i'm getting of them in console see this:

image :
image :
image :
image :
image :
image :
image :
image :
image :

here html code:

<label>selecciona tu imagen de seguridad.</label> <div class="aligncenter-img-carosal"> <div id="thumbs" class="margin0"> <div class="item active"> <ul class="thumbs noscript mrgn-lft-minus20"> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle0"     alt="/webteal/resources/common/images/security_images/e27776110f72158c8f1f5e36d0  ef3ceaa225bc76fac5b55d4ab34383f00a9e6b"   onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this).parent().parent().addclass('selected')" src="/webteal/resources/common/images/security_images/e27776110f72158c8f1f5e36d0ef3ceaa225bc76fac5b55d4ab34383f00a9e6b"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle1"  alt="/webteal/resources/common/images/security_images/0f5fa5789f8ce7992a19b9769b 2928f74814eee52277933c68ba60f6653a253d"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/0f5fa5789f8ce7992a19b9769b 2928f74814eee52277933c68ba60f6653a253d"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle2"  alt="/webteal/resources/common/images/security_images/5a26b22171215c52666b0b9daf 8d14d49320d6be23ec9dca0d78dd5885a43299"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/5a26b22171215c52666b0b9daf 8d14d49320d6be23ec9dca0d78dd5885a43299"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle3"    alt="/webteal/resources/common/images/security_images/98a43db45f0ae431c4b5248697 4ee55952c9f8e18524b42758f69cc1a806a940"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/98a43db45f0ae431c4b5248697 4ee55952c9f8e18524b42758f69cc1a806a940"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle4"  alt="/webteal/resources/common/images/security_images/856113c50b3bfd77ee7e37ad02 c1b59099819306bf47c15e34d1ed86c7c2baed"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/856113c50b3bfd77ee7e37ad02 c1b59099819306bf47c15e34d1ed86c7c2baed"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle5"  alt="/webteal/resources/common/images/security_images/5666c6ea2bd28dd0dfc2b729ad 4463468e329119d451b2fe527c977be50f4f3d"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/5666c6ea2bd28dd0dfc2b729ad 4463468e329119d451b2fe527c977be50f4f3d"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle6"    alt="/webteal/resources/common/images/security_images/5c72f4c79762696f172fb57f84 04989913bd1eccb51b40d96b6b253e4709c7f0"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/5c72f4c79762696f172fb57f84 04989913bd1eccb51b40d96b6b253e4709c7f0"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle7"  alt="/webteal/resources/common/images/security_images/9ff2c1606e3f7c0e826ea450e3 f370edcc4056238536e5150de1c1c720530787"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this). parent().parent().addclass('selected')"  src="/webteal/resources/common/images/security_images/9ff2c1606e3f7c0e826ea450e3 f370edcc4056238536e5150de1c1c720530787"> </a> </li> <li> <a class="thumb" rel="history" href="#"> <img id="secimgtitle8"     alt="/webteal/resources/common/images/security_images/2ddf13da509afa241f331c2f9231b47d2886c5fcf0299608ccd391b30b0772b3" onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this).parent().parent().addclass('selected')" src="/webteal/resources/common/images/security_images/2ddf13da509afa241f331c2f9231b47d2886c5fcf0299608ccd391b30b0772b3"> </a>  </li> <li style="margin-left: 34.1% !important"> <a class="thumb" rel="history" href="#"> <img id="secimgtitle9"   alt="/webteal/resources/common/images/security_images/fccead8b650707de222a5a2f71 9cf0020ba881331b79e01704b7a3d496d0c9d1"  onclick="$('li.selected').removeclass('selected');selectthisimage(this);$(this).parent().parent().addclass('selected')" src="/webteal/resources/common/images/security_images/fccead8b650707de222a5a2f719cf0020ba881331b79e01704b7a3d496d0c9d1"> 

the class "thumb" on <a> tags, not on images. change findelements() call by.cssselector(".thumb > img")


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -