vali83
vali83

Reputation: 157

Webdriver returns error for textarea.sendKeys(text)

I am using Webdriver 2.25.0 and Firefox 14

I have the following textarea:

<textarea id="source-text" placeholder="Start typing your text" style="resize: none; overflow: hidden;"></textarea>

I am identifying this text area in my HomePage object like this:

@FindBy(how = How.CSS, using = "div.myclass textarea")
public WebElement columnLeftTextarea;

What i want to do is simply type some text inside this textarea, by using the following code

homePage.columnLeftTextarea.sendKeys("some text");

This is returning the following error:

Type mismatch Can't assign non-array value to an array

The textarea is correctly defined as when i run

 homePage.columnLeftTextarea.getAttribute("placeholder")

i get the correct text

I even tried to do start the browser by setting the capabilities to tnable native events:

FirefoxProfile ffProfile = new FirefoxProfile(new File(generalPropertiesTestObject.getFirefox_profile_template_location()));
        ffProfile.setEnableNativeEvents(true);
        FirefoxDriver ffd = new FirefoxDriver(ffProfile);
        capabilities = ffd.getCapabilities();

But still i am getting the same error. Does anyone have any idea about it?

Upvotes: 0

Views: 11590

Answers (2)

Arek
Arek

Reputation: 2021

Try firstly focusing into textarea. I did it using the following code:

 driver.findElement(By.id("source-text")).clear();
 driver.findElement(By.id("source-text")).sendKeys("some text");

and it seems to work just fine.

Upvotes: 4

Yury Staravoitau
Yury Staravoitau

Reputation: 175

You need change this code:

@FindBy(how = How.CSS, using = "div.myclass textarea")
public WebElement columnLeftTextarea;

on this:

@FindBy(how = How.ID, using = "source-text") 
public WebElement columnLeftTextarea;

Firstly, it works more faster, because search by ID works more faster than search by CSS. Secondly, ID changes is not so much time as CSS.

Upvotes: 0

Related Questions