http://code.google.com/p/selenium/source/detail?r=12662
Added:
/trunk/java/client/src/org/openqa/selenium/internal/selenesedriver/GetActiveElement.java
Modified:
/trunk/java/client/src/org/openqa/selenium/SeleneseCommandExecutor.java
/trunk/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java
=======================================
--- /dev/null
+++
/trunk/java/client/src/org/openqa/selenium/internal/selenesedriver/GetActiveElement.java
Thu Jun 30 15:55:05 2011
@@ -0,0 +1,43 @@
+/*
+Copyright 2011 WebDriver committers
+Copyright 2011 Google Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package org.openqa.selenium.internal.selenesedriver;
+
+import static org.openqa.selenium.net.Urls.urlEncode;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import com.thoughtworks.selenium.Selenium;
+
+import java.util.Map;
+
+public class GetActiveElement implements SeleneseFunction<Map<String,
String>> {
+
+ private static final String SCRIPT = Joiner.on('\n').join(
+ "(function() {",
+ " var doc = selenium.browserbot.getDocument();",
+ " var el = doc.activeElement || doc.body;",
+ " el = core.firefox.unwrap(el);",
+ " return bot.inject.cache.addElement(el);",
+ "})()");
+
+ public Map<String, String> apply(Selenium selenium, Map<String, ?> args)
{
+ String key = selenium.getEval(SCRIPT);
+ String locator = "stored=" + urlEncode(key);
+ return ImmutableMap.of("ELEMENT", locator);
+ }
+}
=======================================
--- /trunk/java/client/src/org/openqa/selenium/SeleneseCommandExecutor.java
Thu Jun 16 14:39:11 2011
+++ /trunk/java/client/src/org/openqa/selenium/SeleneseCommandExecutor.java
Thu Jun 30 15:55:05 2011
@@ -27,6 +27,7 @@
import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENT;
import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENTS;
import static org.openqa.selenium.remote.DriverCommand.GET;
+import static org.openqa.selenium.remote.DriverCommand.GET_ACTIVE_ELEMENT;
import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_URL;
import static
org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_ATTRIBUTE;
import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_SIZE;
@@ -64,6 +65,7 @@
import org.openqa.selenium.internal.selenesedriver.ExecuteScript;
import org.openqa.selenium.internal.selenesedriver.FindElement;
import org.openqa.selenium.internal.selenesedriver.FindElements;
+import org.openqa.selenium.internal.selenesedriver.GetActiveElement;
import org.openqa.selenium.internal.selenesedriver.GetCurrentUrl;
import org.openqa.selenium.internal.selenesedriver.GetElementAttribute;
import org.openqa.selenium.internal.selenesedriver.GetElementText;
@@ -179,6 +181,7 @@
addCommand(FIND_ELEMENTS, findElements);
addCommand(IMPLICITLY_WAIT, timeouts);
addCommand(GET, new GetUrl());
+ addCommand(GET_ACTIVE_ELEMENT, new GetActiveElement());
addCommand(GET_ELEMENT_ATTRIBUTE, new GetElementAttribute());
addCommand(GET_ELEMENT_SIZE, new GetSize());
addCommand(GET_ELEMENT_TEXT, new GetElementText());
=======================================
---
/trunk/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java
Mon Jun 27 03:55:48 2011
+++
/trunk/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java
Thu Jun 30 15:55:05 2011
@@ -203,7 +203,7 @@
}
@JavascriptEnabled
- @Ignore(value = {SELENESE,IPHONE}, reason = "iPhone: focus doesn't
change as expected")
+ @Ignore(value = {IPHONE}, reason = "iPhone: focus doesn't change as
expected")
public void testShouldBeAbleToSwitchToFocusedElement() {
driver.get(pages.javascriptPage);
@@ -214,7 +214,7 @@
}
@JavascriptEnabled
- @Ignore({SELENESE, IPHONE})
+ @Ignore({IPHONE})
public void testIfNoElementHasFocusTheActiveElementIsTheBody() {
driver.get(pages.simpleTestPage);