简体   繁体   中英

How to select an item that is in a drop down menu coded in CSS for Selenium IDE?

Thanks so much for reading my question. I am inquiring about selecting an item that exists in a drop down menu. The drop down menu is coded in CSS.

The change in the Javascript is from

a class="chzn-single"

to selecting the item

a class="chzn-single-with-drop"

back to

a class="chzn-single"

I look forward to any and all help. If there's any questions, please don't hesitate to reach out and thanks again for looking at my question.

If using Jquery to select an element by class name

$(".chzn-single")

if you dont have jquery included you can do this by vanilla Js by Declaring a function

function getElementByClass (className, parent) {
  parent || (parent = document);
  var descendants= parent.getElementsByTagName('*'), i=-1, e, result=[];
  while (e=descendants[++i]) {
    ((' '+(e['class']||e.className)+' ').indexOf(' '+className+' ') > -1) && result.push(e);
  }
  return result;
}

and calling the declared function

var element1 = getElementByClass("a", "chzn-single");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM