because my B593 router is sometimes stuck in a state where it produces around 50% packet loss i am trying to write a program to let it automatically reboot if lets say out of the last 100 pings 30 are lost.

I am having trouble to click on the actual reboot button itself, it seems that it gets loaded by some Javascript but watir is not able to see the button. Having googled quite a bit it seems that i need to provide the path to this button which i am currently trying to do - but so far no luck.

If anybody could shed some light it would really make my and probably some other B593 owners day as well.

**This is what google inspector says when i click "Copy XPath" over the reboot button.**

```
//*[@id="btnReboot"]

```

**This is what the reboot button looks in the frames source code.**

```
<button onclick="reboot()" id="btnReboot">
<script>document.write(gVarReboot);</script>Reboot
</button>

```

**Page source code**

```
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>content</title>
<script language='javascript'>
var REFRESH_TIME = 60000;
var ssidIdx = 0;
var lanDevIndex = 0;
var dhcpOptRedio = 0;
var QoSCurInterface = '';
var DDNSProvider = '';
var ripIndex = "";
var previousPage = "";
var preAddDomain = "";
var editIndex = -1;
var editDomain = '';
var g_FWLevel = -1;
var g_LevelOptRedio = 0;
var g_oMenuTree = null;
var curUserType = "0";
var sptUserType = '0';
var sysUserType = '1';
var aplyLine = -1;
var Link = "/html/help/help_content.html#";
var x = parseInt(screen.width / 2);
var y = parseInt(screen.height / 2);
var g_url = '';
var g_firstmenu = 'Admin_0';
var g_secondmenu = 'Admin_0_0';
var g_thirdmenu = 'Admin_0_0_0';
var errStrStr = '';
var errIdCtrlStr = '';
var updateIncoming = 0;
var g_IsVpnCertsUploaded = 0;
var g_is_refresh = true;
var g_modifiedFlg = false;
var ipfiltertablelist = null;
var g_wlanBasicSetting = "1";
var g_expendUpgDiv = true;
var g_smsType='0';
var g_isFromPinPage = false;
function addTimer() {
setInterval("resetModifiedFlg();", REFRESH_TIME);
}
function resetModifiedFlg() {
try {
if (top.g_modifiedFlg) {
top.g_modifiedFlg = false;
top.frames["hiddenfrm"].location
.replace("/html/main/hidden.asp");
}
} catch (e) {
var forjslint = 0;
}
}
</script>
<script language="JavaScript">
</script>
<frameset rows='68,*,20' border='0' frameborder='no' framespacing='0'
onload="addTimer();">
<frameset cols='0,0,0,*' frameborder='0' border='0'>
<frame src='/html/main/refresh.asp' name='connfrm' id='connfrm'
frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0' noresize></frame>
<frame src='/html/main/hidden.asp' name='hiddenfrm'
id='hiddenfrm' frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0' noresize></frame>
<frame src='' name='helpfrm' id='helpfrm' frameborder='no'
border='0' scrolling='no' marginwidth='0'
marginheight='0' noresize></frame>
<frame src='/html/main/logo.asp' name='logofrm' id='logofrm'
frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0'></frame>
</frameset>
<frameset cols='200,*,0' frameborder='0' border='0'>
<frame src='/html/main/menu.asp' name='menufrm' id='listfrm'
frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0' noresize></frame>
<frame src='' name='contentfrm' id='contentfrm' frameborder='0'
border='0' scrolling='auto' marginwidth='0'
marginheight='16' noresize></frame>
<frame src='' name='uploadFrm' id='uploadFrm'
frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0' noresize></frame>
</frameset>
<frame src='/html/main/footer.html' name='footerfrm'
frameborder='no' border='0' scrolling='no'
marginwidth='0' marginheight='0' noresize></frame>
</frameset>
<noframes>
The information on the page makes use of frame technology. For best
results, use the new version of Browser.
</noframes>
</head>
</body>
</html>

```

**Frame Source Code**

```
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/loadbyver.js?ver=V100R001C56SP052"></script>
<script type="text/javascript">
loadCss("/css/newcommon.css");
loadCss("/css/contentstyle.css");
loadCss("/lang/lang.css");
loadRes("/lang/reset.res");
loadJs("/js/util/base.js");
loadJs("/js/util.js");
loadJs("/js/tabinfo.js");
loadJs("/js/reset.js");
</script>
</head>
<body>
<div class="page_container"><div id="page_path" class="page_path">&nbsp;</div>
<table cellspacing=0 cellpadding=0 class="layout_table">
<tr>
<td class="layout_top_gap">
</td>
</tr>
<tr>
<td>
</td>
<td class="layout_center_td">
<table cellspacing=0 cellpadding=0 class="layout_title_table" id="layoutPageTitleId">
<tr>
<td class="layout_title_td">
<script type="text/javascript">
document.write(gVarReset);
</script>
</td>
</tr>
</table>
<table class="page_all_table" cellspacing="0" cellpadding="0">
<tr class="page_all_tr">
<td class="page_td_gap_left"></td>
<td class="page_all_content_td" id="page_all_content_td">
<table cellspacing=0 cellpadding=0 class="page_top_discription" id="pageTopDiscriptionId" >
<tr>
<td id="pageTopDiscriptionTdId" class="page_op_iscription_td">
<script type="text/javascript">
document.write(gVarPageComment);
</script>
</td>
</tr>
</table>
<div class="module_container">
<table cellspacing="0" cellpadding="0" class="module_header">
<tr>
<td id="id_rebootTitle">
<div class="module_header_title">
<div class="module_header_title_bg_left"></div>
<div class="module_header_title_text"><script>
document.write(gVarReboot);
</script></div>
<div class="module_header_title_bg_right"></div>
</div>
</td>
</tr>
</table>
<table id="id_rebootBody" cellspacing="0" cellpadding="0"
class="module_content" >
<tr>
<td style="border:none" align="left">
<div  style="margin-left:15px; margin-top : 15px;">
<script language="JavaScript" type="text/javascript">
document.write(gVarClickrebootb);
</script>
</div>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" class="module_bottom">
<tr>
<td>
<div>
<button onclick="reboot()" id="btnReboot">
<script>document.write(gVarReboot);</script>
</button>
</div>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" class="module_header">
<tr>
<td id="id_restoreTitle">
<div class="module_header_title">
<div class="module_header_title_bg_left"></div>
<div class="module_header_title_text">
<script>
document.write(gVarRestoreDefalut);
</script>
</div>
<div class="module_header_title_bg_right"></div>
</div>
</td>
</tr>
</table>
<table id="id_restoreBody" cellspacing="0" cellpadding="0"
class="module_content" >
<tr>
<td style="border:none" align="left">
<div  style="margin-left:15px; margin-top : 15px;">
<script language="JavaScript" type="text/javascript">
document.write(gVarClickRestoreD);
</script>
</div>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" class="module_bottom">
<tr>
<td>
<div>
<button onclick="restoreDefalut()" id="btnResory">
<script>document.write(gVarRestoreDefalut);</script>
</button>
</div>
</td>
</tr>
</table>
</div>
<div>&nbsp;</div>
<div id="erroinfo"  style="width:100%; display:none"></div>
</td>
<td style="width:10px;"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" class="module_bottom">
<tr>
<td class="layout_left_corner">
</td>
<td>
&nbsp;
</td>
<td  class="layout_right_corner">
</td>
</tr>
</table>
</td>
<td class="layout_center_gap">
</td>
<td class="page_td_help_layout">
<div class="layout_help_top_div" id="id_layout_help_top_div"></div>
<div style=" padding:10px;">
<div id="page_all_help_td" ></div>
</div>
</td>
<td class="layout_right_gap">
</td>
</tr>
</table>
</div>
</body>
<script>
initPage();
__init();
</script>
</html>

```

**My current code**

```
require "watir-webdriver"

admin_password = 'stackoverflowcanhelp'

#spawn instance
browser = Watir::Browser.new :chrome

#open homepage
browser.goto "http://192.168.0.75"

#set Langauge to english
browser.select_list(:name => 'Language').select 'English'

#enter password
browser.text_field(:name => "Password").set admin_password

#login
browser.a(:id, "btnLogin").click

#go to reboot menue
browser.cookies.add 'FirstMenu', 'Admin_10', :path => "/"
browser.cookies.add 'SecondMenu', 'Admin_10_1', :path => "/"
browser.cookies.add 'ThirdMenu', 'Admin_10_1_0', :path => "/"

#refresh browser
browser.refresh

#reboot router
browser.button(:xpath, '//*[id="btnReboot"]').click #does not work
browser.alert.set "Click "
browser.alert.ok

#close browser
browser.close

```

**error message**

```
gems/watir-webdriver-0.6.2/lib/watir-webdriver/elements/element.rb:490:in `assert_exists': unable to locate element, using {:xpath=>"//*[id=\"btnReboot\"]", :tag_name=>"button"} (Watir::Exception::UnknownObjectException)
    from /Users/stackoverflowfan/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/watir-webdriver-0.6.2/lib/watir-webdriver/elements/element.rb:118:in `click'
    from a.rb:29:in `<main>'

```