How to write some text in textarea on a webpage using Selenium WebDriver

14 144 wyświetlenia
Przejdź do pierwszej nieodczytanej wiadomości

sachin ahuja

nieprzeczytany,
23 lip 2014, 03:23:1623.07.2014
do seleniu...@googlegroups.com
Hi,

I am using below code to write text in textarea on a webpage.

WebDriver driver=new FirefoxDriver();
driver.findElement(By.id("
description")).sendkeys("some value");

// This code write character by character.

I tried same with JavascriptExecutor with below code for textbox(input tag) but it doesn't work for textarea.

WebElement element=driver.findElement(By.id("description"));
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("arguments[0].setAttribute('value',arguments[1]);",element,"some value);


Please help me to write some text in textarea tag. That will be replacement of "sendKeys()".


Thanks
Sachin Ahuja

Jianfeng Sun

nieprzeczytany,
23 lip 2014, 13:34:0323.07.2014
do seleniu...@googlegroups.com
I'm using sendkeys for textarea and facing no issue. Good practice will be to do a clear before you sendkeys. Sometimes, you need to activate the field first before you can enter anything.  If this won''t help, please specific what kind of error you are getting. 
Wiadomość została usunięta

sachin ahuja

nieprzeczytany,
24 lip 2014, 07:14:0924.07.2014
do seleniu...@googlegroups.com
Yes, sendkeys is working fine.
But when I am having large text to enter, it is taking extra time.

I am looking for an alternative to sendKeys

Deepthi

nieprzeczytany,
24 lip 2014, 13:33:3824.07.2014
do seleniu...@googlegroups.com
public class no_sendkeys {
public static void setAttribute(WebElement element, String attributeName, String value)
{
WrapsDriver wd = (WrapsDriver) element;
JavascriptExecutor driver = (JavascriptExecutor)wd.getWrappedDriver();
driver.executeScript("arguments[0].setAttribute(arguments[1],arguments[2])", element, attributeName, value);
}


public static void main(String[] args) 
{
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement input_user=driver.findElement(By.xpath("//*[@id='email']"));
setAttribute(input_user,"value","Deepthi");
}

}


On Wednesday, July 23, 2014 12:23:16 AM UTC-7, sachin ahuja wrote:
Wiadomość została usunięta

sachin ahuja

nieprzeczytany,
29 lip 2014, 07:49:2629.07.2014
do seleniu...@googlegroups.com
Hi Deepthi,

I am using the same code as..

WebDriver driver=new FirefoxDriver();
element=objWebDriver.findElement(By.xpath("//textarea[@id='description']"));
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("arguments[0].setAttribute('value',arguments[1]);",element,"some value);


Please help me to resolve this.

Thanks,

ani0...@gmail.com

nieprzeczytany,
29 lip 2014, 09:31:2629.07.2014
do seleniu...@googlegroups.com
Sachin what is the application u r automating?may be u r taking wrong selector.

Instead of send keys can u try with clipboard fun ctionality?

Sent from BlackBerry10® on Airtel
From: sachin ahuja
Sent: Tuesday 29 July 2014 5:14 PM
Subject: [selenium-users] Re: How to write some text in textarea on a webpage using Selenium WebDriver

Hi Deepthi,

It didn't work.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6786f60d-ded2-441a-a8ff-efdc259ae4e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sachin ahuja

nieprzeczytany,
29 lip 2014, 10:00:1229.07.2014
do seleniu...@googlegroups.com
Animesh, I am using "http://www.jobzoom.com/main/dashboard/" this website and trying to automate this.
After logon to this, their is an field for Job Description.

Below tag is used for textarea :

<textarea id="description" class="validate['required']" name="description" cols="75" style="border: 2px solid rgb(221, 221, 221); background-color: rgb(255, 255, 255);" rows="16"></textarea>


Deepthi

nieprzeczytany,
29 lip 2014, 18:27:1829.07.2014
do seleniu...@googlegroups.com
Hi Sachin

Use the attribute placeholder

public class jobzoom_TextArea {

        public static void setValue(WebElement element, String attributeName, String value)
{
WrapsDriver wd = (WrapsDriver) element;
JavascriptExecutor driver = (JavascriptExecutor)wd.getWrappedDriver();
driver.executeScript("arguments[0].setAttribute(arguments[1],arguments[2])", element, attributeName, value);
}

public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();

               WebElement textarea=driver.findElement(By.xpath("//*[@id='description']"));
setValue(textarea,"placeholder","selenium webdriver java");

Deepthi

nieprzeczytany,
29 lip 2014, 18:43:2129.07.2014
do seleniu...@googlegroups.com
Hi Sachin,

Sorry sachin the below code doesn't work in the  way as it is supposed to do.

Thanks
Deepthi

sachin ahuja

nieprzeczytany,
30 lip 2014, 11:00:3030.07.2014
do seleniu...@googlegroups.com
Yeah, I had already tried for "Placeholder" attribute, but it behave in different manner.

jeevan

nieprzeczytany,
30 lip 2014, 11:04:0530.07.2014
do seleniu...@googlegroups.com
Try this,

JavascriptExecutor js =  (JavascriptExecutor)driver;
js.executeScript("document.getElementById('description').value='ABCD');

Thanks,
Jeevan



On Wed, Jul 30, 2014 at 10:00 AM, sachin ahuja <sachin...@gmail.com> wrote:
Yeah, I had already tried for "Placeholder" attribute, but it behave in different manner.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

vandana singh

nieprzeczytany,
26 lip 2018, 14:28:4226.07.2018
do Selenium Users
Hi,
Can some one help me for below scenario:

how to take input from xml file in webpage-textarea using selenium webdriver with java?

Thanks

vandana singh

nieprzeczytany,
26 lip 2018, 14:32:4426.07.2018
do Selenium Users
I am trying to take a very big data in text area as input and it is located in some folder in xml format.please help. 
Thanks, 
Vandana 


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0