Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

sendKeys appends text to URL rather then web element in Selenium 2.6.0 for firefox 6 #2487

Closed
lukeis opened this issue Mar 3, 2016 · 12 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2487

The problem: Executing sendKeys seems to append the text to the url rather than into
the element specified when automating a Google Search.
Frequency: Happens every time I run the test

What I've tried so far:
* If I change back to 2.5.0, the problem does not occur
* If I change the code to perform a Yahoo search instead of Google search, the problem
does not occur
* If I change the driver to InternetExplorerDriver, the problem does not occur
* If I put a line of code to click on an element between the call to "get" and "sendKeys",
the problem does not occur (e.g. code inserted: driver.findElement(By.id("hplogo")).click();)
* If I put a Thread.sleep(1000) in between the call to "get" and "sendKeys", the problem
still occurs

Steps to reproduce
OS: Windows 7 64bit, Browser: Firefox 6.0.2
Dependency in pom.xml:
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.6.0</version>
</dependency>

Test case:

public void canPerformSimpleSearch() {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://google.com");
    driver.findElement(By.id("lst-ib")).sendKeys("Selenium");
    Assert.assertEquals(driver.findElement(By.id("lst-ib")).getAttribute("value"), "Selenium");
    driver.close();
}

Reported by paola.pettit on 2011-09-17 22:19:35

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

this is also happening using the Ruby example provided on the webpage

https://gist.github.com/1227043 

Reported by llaskin on 2011-09-19 17:49:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Note: this occurs on yahoo for us as well (just change :name => "p")

Reported by llaskin on 2011-09-19 17:50:40

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm seeing this in Python also.

(Python 2.7, Ubuntu 11.04, Selenium 2.6.0)

consider the following snippet:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('http://google.com/')

# expected: type into search box
# actual: type/append to URL
element = driver.find_element_by_id('lst-ib')
element.send_keys('Cheese')

# expected: type into search box
# actual: type/append to URL
element = driver.find_element_by_name('q')
element.send_keys('Please')


I also noticed if you add a element.clear() between selecting an element and using
send_keys(), this does not occur.

Reported by cgoldberg on 2011-09-19 19:41:11

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

note: i can only reproduce this in Firefox (6.02).  It works normally in Chrome.

Reported by cgoldberg on 2011-09-19 19:45:47

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

reproduced the issue in 2.6  on win7 ff6  (could not reproduce on mac ff3.6). Also reproduced
on yahoo, bing and ask.

2.5 does not have this issue.

I noticed a lot of changes that happened between 2.5 and 2.6 to:
javascript/firefox-driver/extension/components/wrappedElement.js

Reported by luke.semerau on 2011-09-19 21:23:40

  • Status changed: Accepted
  • Labels added: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 2500 has been merged into this issue.

Reported by dawagner on 2011-09-20 10:54:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

only workaround to avoid this bug for the time being i saw was to use sendKeys("").clear()
before the first send key call made after opening the URL.

Something like

driver.findElement(By.name("USERNAME")).clear();
WebElement Uname = driver.findElement(By.name("USERNAME"));
WebElement pwd = driver.findElement(By.name("PIN"));
WebElement loginBtn = driver.findElement(By.name("imgBtn0"));

Uname.sendKeys("ServiceDesk");
pwd.sendKeys("asd");
loginBtn.click();

Reported by Talwindersingh on 2011-09-20 11:49:39

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Sorry for the mistake.

I meant driver.findElement().clear()


Reported by Talwindersingh on 2011-09-20 12:08:17

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision r13892.

Reported by simon.m.stewart on 2011-09-21 19:25:15

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 2465 has been merged into this issue.

Reported by luke.semerau on 2011-09-23 15:41:46

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Issue 2524 has been merged into this issue.

Reported by dawagner on 2011-09-26 12:09:03

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:13:45

  • Labels added: Restrict-AddIssueComment-Commit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant