Selenium-webdriver java dropdown issue element should have been select -
i have html code dropdown:
<div class="column two"> <select id="cctype" name="cctype"> <option value="">please select...</option> <option value="mcard">master card</option> <option value="visa ">visa</option> </select>
my script:
javascriptexecutor js = (javascriptexecutor) driver; js.executescript("arguments[0].select();", selectcreditcardtype); selectcreditcardtype.selectbyvalue("visa");
or
selectcreditcardtype.selectbyvisibletext(customer.creditcardtype);
result: element should have been select
input
.
tried different options stackoverflow: selenium webdriver c# css dropdown issue - element should have been select div no luck yet.
it should work if utilize openqa.selenium.support.ui.selectelement class
c# example:
var selelement = new openqa.selenium.support.ui.selectelement([web element goes here]); foreach (var alternative in selelement.options) { if (option.text == "desired text here") selelement.selectbytext(option.text); }
you can value, attribute selection , comparing on alternative of select element.
option.getattribute("value");
java webdriver
No comments:
Post a Comment