Hi Simon,
I ended up looking into this a bit more and found the problem.
Basically it only happens when calling findElement(By.tagName("blah"))
on WebDriver but not when it's calling it on WebElement. This is
because it translates to the command name "selectElementByTagName"
being sent which doesn't exist in the Firefox extension. I changed the
command to use "selectElementUsingTagName" which does exist and got a
bit further. This time it failed because of a couple of typos in the
javascript function which were easy to fix. There aren't any tests
around finding by tag name using the driver so I added a couple in
ElementFindingTest.
If I could work out how to upload a file to this group I would attach
a patch, but either I'm a bit thick or I'm not allowed to so I've
pasted the diff below.
There's also a problem with socketListener.js line 282 which tries to
call driver.window on an undefined object when it tries to return an
unrecognised command error. This is what causes the extension to throw
an exception instead of the returning the error message. The driver
variable is defined out of scope but I didn't know the best thing to
do there so thought I'd leave that bit up to you.
Cheers,
Jon
Index: common/test/java/org/openqa/selenium/ElementFindingTest.java
===================================================================
--- common/test/java/org/openqa/selenium/ElementFindingTest.java
(revision 781)
+++ common/test/java/org/openqa/selenium/ElementFindingTest.java
(working copy)
@@ -84,6 +84,24 @@
assertThat(element.isSelected(), is(false));
}
+ @Ignore(SAFARI)
+ public void testShouldfindAnElementBasedOnTagName() {
+ driver.get(formPage);
+
+ WebElement element = driver.findElement(By.tagName("input"));
+
+ assertNotNull(element);
+ }
+
+ @Ignore(SAFARI)
+ public void testShouldfindElementsBasedOnTagName() {
+ driver.get(formPage);
+
+ List<WebElement> elements = driver.findElements(By.tagName
("input"));
+
+ assertNotNull(elements);
+ }
+
public void
testShouldNotBeAbleTofindElementsBasedOnIdIfTheElementIsNotThere() {
driver.get(formPage);
Index: firefox/src/java/org/openqa/selenium/firefox/FirefoxDriver.java
===================================================================
--- firefox/src/java/org/openqa/selenium/firefox/FirefoxDriver.java
(revision 781)
+++ firefox/src/java/org/openqa/selenium/firefox/FirefoxDriver.java
(working copy)
@@ -201,11 +201,11 @@
}
public WebElement findElementByTagName(String using) {
- return findElement("selectElementByTagName", using);
+ return findElement("selectElementUsingTagName", using);
}
public List<WebElement> findElementsByTagName(String using) {
- return findElements("selectElementsByTagName", using);
+ return findElements("selectElementsUsingTagName", using);
}
public WebElement findElementByXPath(String using) {
Index: firefox/src/extension/components/firefoxDriver.js
===================================================================
--- firefox/src/extension/components/firefoxDriver.js (revision 781)
+++ firefox/src/extension/components/firefoxDriver.js (working copy)
@@ -245,7 +245,7 @@
respond.send();
};
-FirefoxDriver.prototype.selectElementsUsingTagName = function
(respond, name) {
+FirefoxDriver.prototype.selectElementUsingTagName = function(respond,
name) {
var doc = Utils.getDocument(this.context);
var elements = doc.getElementsByTagName(name);
@@ -259,7 +259,7 @@
respond.send();
};
-FirefoxDriver.prototype.selectElementsUsingTagName = function
(respond, using) {
+FirefoxDriver.prototype.selectElementsUsingTagName = function
(respond, name) {
var doc = Utils.getDocument(this.context);
var elements = doc.getElementsByTagName(name);
> Nice to know the problem is consistent. I'll make this a priority for
> tomorrow's coding session.
>
> Simon
>
> On Mon, Feb 9, 2009 at 3:38 PM, Jon Spalding
>