Reputation: 11
In Selenium IDE I'm trying to invoke some key shortcuts in browser. For example let's say I want to reload http://www.google.com page with:
sendKeys
//body
${KEY_F5}
Script passes, but is not working. Switching to any frame first also not working.
In webdriver I'm successfully using:
driver.findElement(By.xpath("//body")).sendKeys(Keys.F12);
I'm aware of refresh
command in IDE, but it won't solve my problem because what I really need to do is send different F1-12
keys...
Am I missing something?
I've also tried click first at body element but I'm not able to make it work and send any F1-12
keys to window/page and not to an element.
Upvotes: 1
Views: 3351
Reputation: 176
Run the following code and you will see how your sendKey KEY_F5 is working. when script reaches sendKeys, the searchbar is being triggered It is my guess that body is being refreshed not the whole document. Not sure..though
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.com/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/?gws_rd=ssl</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=lst-ib</td>
<td>dsad</td>
</tr>
<tr>
<td>click</td>
<td>name=btnG</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>//*</td>
<td>${KEYS_F5}</td>
</tr>
</tbody></table>
</body>
</html>
Upvotes: 1