0
votes

I've just prepared a load test with WebDriver Sampler. I'm using selenium-chrome-driver-2.39.0.jar,selenium-firefox-driver-2.39.0.jar, JMeter 2.11 and FireFox 26.0. When I'm using Chrome Driver Config, there is no error. But when I'm using same script with FireFox Driver Config, I get an error. The error is :

Response message: org.openqa.selenium.InvalidElementStateException: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsINativeMouse.click]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::

I want to click

<option value="12">12< /option>

with

var selectCCMonth = WDS.browser.findElement(lib.By.cssSelector('.ccMonth option:nth-of-type(13)'))
selectCCMonth.click() 

The above code is working on Chrome Driver Config but not working on FireFox Driver Config.

html is:

<select class="clsSelect pie ccMonth required normalSelect valid" name="ExpirationDateMonth" id="ccMonth" title="Zorunlu" style="border: 1px solid rgb(214, 214, 214);">
    <option value="">Ay</option>
    <option value="1">01</option>
    <option value="2">02</option>
    <option value="3">03</option>
    <option value="4">04</option>
    <option value="5">05</option>
    <option value="6">06</option>
    <option value="7">07</option>
    <option value="8">08</option>
    <option value="9">09</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
</select>

How can I handle this problem?

3

3 Answers

2
votes

Looking into <select> tag I guess that you're trying to choose a value from a dropdown. In Selenium world it needs to be done a little bit differently. Take a look into Select class in general and selectByVisibleText method in particular.

Example code will look like:

var element = WDS.browser.findElement(lib.By.cssSelector('.ccMonth option:nth-of-type(13)'))
var select = new org.openqa.selenium.support.ui.Select(element)
select.selectByVisibleText('12')

For more WebDriver sampler tips and some kind of FAQ on the most commonly asked things take a look at The WebDriver Sampler: Your Top 10 Questions Answered guide.

0
votes

Can u please try by creating a Select object and then use selectByVisibleText method?

(this method is in java, please checkout for the relevant in your preferred language.)

Hope this might help.

For what went wrong u can refer to this link.

0
votes

I've just found a solution for that.

I added that code into my script

WDS.browser.executeScript('$(".ccMonth").val(12);')

and it worked.