Monkomatic has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I am having great difficulty In the new Selenium Webdriver 2.0. I have found Some old 2012 web snippets stating Select did not work in PERL. Only java. If this is true anyone know a workaround?
A) FINDING THE ELEMENT(THE OTHERS SEEM TO WORK FINE)
B) SETTING THE ELEMENT TO THE OPTION.
I had no difficulty in the old selenium RC. I have tried the following perl code to no avail.
(using http://search.cpan.org/~aivaturi/Selenium-Remote-Driver-0.15/lib/Selenium/Remote/Driver.pm)
Anyone have an idea on the call? I am simply trying to set the option to Blue. I Have tried everything i can think of Name ,css,xpath,ID,class etc....
</div> <div class="cpl-gm-9 cpl-mk-10 cpl-lg-7"> <div class="col-group col-flush"> <div class="col-mj-4 gr-mc-0 mb-df-1 dm-md-0"> <div class="has-validation"> <label class="select-wrap"> <label for="color" class="label-sr">What Color +?</label> <select id="color" data-field="color" class="s +elect select-custom"> <option value="">What Color?</option> <optgroup label="Select Color"> <option value="Blue">Blue</option> <option value="Green">Green</optio +n> <option value="Yellow">Yellow</opt +ion> </optgroup> </select> </label> </div> </div>
#WORKS BUT GOES NOWHERE #my $element = $driver->find_element( '//div[@class="cpl-gm-9 cpl-mk-1 +0 cpl-lg-7"]' ) ;CANT SELECT USING THIS. BUT AT LEAST DOESNT DUMP TO + ERROR #my $elem1 = $driver->find_element('//div[@class="cpl-gm-9 cpl-mk-10 c +pl-lg-7"]'); #DOESNT WORK #my @child = $driver->find_child_elements($elem1, "//option"); #print "@child"; #my $elem = $driver->find_element("//input[\@id='color']");$driver->mo +use_move_to_location(element => $elem, xoffset => 0, yoffset => 0); +$driver->click; #COUNT THE DIVS- TO MANY DIVS (USED FIREBUG) my $element = $driver->find_element('html/body/div[4]/section/div/div[ +4]/div[1]/div/div/div[2]/div[1]/div/div[3]/div[4]/div/div/div[2]/div/ +div[1]/div/label/select');$element->set_selected('Blue'); #my $element = $driver->find_element("//select[contains(\@id, 'color') +]");$element->set_selected('Blue'); #GET ALL ELEMENTS ON PAGE (DOESNT SEEM TO WORK) SHOUDNT IT??? (GOT IT +FROM A WEBSITE) #my @elements = $driver->find_elements('//*');
|
|---|