Entered text is got washed away

40 views
Skip to first unread message

Sonia saini

unread,
Aug 3, 2015, 5:48:42 AM8/3/15
to seleniu...@googlegroups.com
Hi,

I have to entered in text field then click on outside the element to make "next" button visible.But 
by suing javascript executer it is getting wash away.

This is my text input and by using Java script executer after entering it is getting wash away.
String xpath = "//*[@id='samples-grid']/table/tbody/tr/td [last()]";
WebElement e = getWebDriver().findElement(By.xpath(xpath));
sendKeysByJavascriptAndTriggerEvents(e,keysToSend);
Method
private void sendKeysByJavascriptAndTriggerEvents(WebElement webElement, String keysToSend) {

// trigger the change event.
executeWebDriverJS(webElement, "$(arguments[0]).change(); return true;");

// trigger the blur and keyup to simulate keypresses.
executeWebDriverJS(webElement, "$(arguments[0]).blur(); return true;");
executeWebDriverJS(webElement, "$(arguments[0]).keyup(); return true;");

// clicking away from an element can trigger an event.
getWebDriver().findElement(By.tagName("body")).click();
I have tried Actions API as well but it did not help me.

Actions act = new Actions(getWebDriver());
act.moveToElement(e).doubleClick(e).build().perform();
act.sendKeys(e, Keys.TAB).build().perform();
act.contextClick(e).release(e);
        act.sendKeys(e,Keys.ENTER).build().perform()
At Run time only this text is becoming Input type and I am using Action API for double click then entering Key.

Sonia saini
Screen Shot 2015-08-03 at 3.17.04 pm.png

Sonia saini

unread,
Aug 3, 2015, 5:54:40 AM8/3/15
to seleniu...@googlegroups.com
Sorry for typo mistakes in words. Please ignore those words.
--
Sonia saini

Kaleem Uddin Mohammed Abdul

unread,
Aug 3, 2015, 6:12:24 AM8/3/15
to Selenium Users
Instead of clicking anywhere, I have below solution, please let me know whether it works.

e.SendKeys("TextWhich You want to sent"+Keys.TAB);
Thread.Sleep(2000);

Sonia saini

unread,
Aug 3, 2015, 6:33:27 AM8/3/15
to seleniu...@googlegroups.com
Already tried this one as well.

String xpath = "//*[@id='samples-grid']/table/tbody/tr/td [last()]";
WebElement e = getWebDriver().findElement(By.xpath(xpath));
e.sendKeys(keysToSend + "\n");
e.sendKeys(Keys.TAB);
The problem is here focus still remain on input box only. Is there any way to get mouse cursor in the end of entered keys? 



--
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/0633d0b4-8a3d-4763-a5a2-b63e0f880faf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sonia saini

Kaleem Uddin Mohammed Abdul

unread,
Aug 3, 2015, 7:37:08 AM8/3/15
to Selenium Users
Manually can you try i.e. Update the input field with text and TAB. See whether the Next button is visible or not. If manually it works then using Selenium it should work.

Also, in your screen shot, the span tag is not expanded. I believe under span tag we may have input tag. You need to send keys to this input. Look at my screen shot.


On Monday, August 3, 2015 at 3:18:42 PM UTC+5:30, niya wrote:
Answer.jpg

Sonia saini

unread,
Aug 3, 2015, 9:11:01 AM8/3/15
to seleniu...@googlegroups.com
I am able to enter value in input text box but can not do tab and enter. Yes, Manually it is working.

I have also tried another work around but did not work too.

String xpath = "//*[@id='samples-grid']/table/tbody/tr/td [last()]/span[1]/span/input[1]";
WebElement e = getWebDriver().findElement(By.xpath(xpath));


Actions act = new Actions(getWebDriver());
 act.moveToElement(e).click();
e.clear();
// e.sendKeys(keysToSend, Keys.ENTER);
act.keyDown(e,Keys.CONTROL);
act.sendKeys(e,keysToSend);
act.keyUp(e,Keys.ENTER);
act.doubleClick(e).contextClick().build().perform()

--
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.

For more options, visit https://groups.google.com/d/optout.



--
Sonia saini

Kaleem Uddin Mohammed Abdul

unread,
Aug 3, 2015, 11:22:26 AM8/3/15
to Selenium Users
What's the error?
Why can't we just say e.sendkeys("text"+Keys.TAB)?

Sonia saini

unread,
Aug 3, 2015, 11:28:55 PM8/3/15
to seleniu...@googlegroups.com
There is no error in selenium.

I have tried e.sendkeys("text" +Keys.Tab); rather then "text" I am making it dynamic and entering it with using random utility function.

In debug mode I don't get any error but what I see if we can get mouse cursor end of entered keys then we can over come on issue. but I don't see any method related to that. 

public void setPresetsTextName(String keysToSend) {
String xpath = "//*[@id='samples-grid']/table/tbody/tr/td [last()]/span[1]/span/input[1]";
WebElement e = getWebDriver().findElement(By.xpath(xpath));

Actions act = new Actions(getWebDriver());
act.moveToElement(e).doubleClick(e).build().perform();
e.clear();
e.sendKeys(keysToSend ,Keys.TAB );
}




On Mon, Aug 3, 2015 at 8:52 PM, Kaleem Uddin Mohammed Abdul <makale...@gmail.com> wrote:
What's the error?
Why can't we just say e.sendkeys("text"+Keys.TAB)?
--
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.

For more options, visit https://groups.google.com/d/optout.



--
Sonia saini
Reply all
Reply to author
Forward
0 new messages