On Aug 5, 10:30 am, Simon Stewart <
simon.m.stew...@gmail.com> wrote:
> Yes:
>
> WebElement active = driver.switchTo().activeElement();
> active.sendKeys("foobar");
Thx. It was not exposed through the Python api. Here is a patch for
firefox/src/py/webdriver.py
@@ -49,7 +49,7 @@
def execute_script(self, script, *args):
"""Executes arbitrary javascript.
For WebElement argument, the format is:
- execute_script("argument[0].value='cheese'", elem)
+ execute_script("arguments[0].value='cheese'", elem)
"""
converted_args = []
for arg in args:
@@ -170,6 +170,15 @@
def find_elements_by_tag_name(self, tag_name):
"""Finds all the elements with the given tag"""
return self._find_elements_by("TagName", tag_name)
+
+ def switch_to_active_element(self):
+ """Returns the focused element"""
+ return WebElement(self, self._command
("switchToActiveElement"))
+
+ def send_keys(self, keys):
+ """Types to the focused element"""
+ focused_element = self.switch_to_active_element()
+ focused_element.send_keys(keys)
def get_page_source(self):
"""Gets the page source."""
Cheers,
Kamil