java 中的 selenium 无法点击 href="javascript:void(0);"
selenium in java cannot click on a href="javascript:void(0);"
这是我正在处理的代码 on.I 我正在尝试点击子菜单。
<ul class="accordion">
<li id="one1" class="files">
<a href="#one1">Accounts</a>
<ul class="sub-menu">
<li>
<a href="#one1" onClick="loadTabv2('accounts/LoadAccountGroupMaster',
'Account Group','accounts_account_group');"><img src="layouts/static/image/micons/account_group.png">Account Group</a>
<a href="#one1" onClick="loadTabv2('accounts/AccountingPeriod',
'Accounting Period','account_accounting_period');"><img src="layouts/static/image/micons/accounting_period.png">Accounting Period</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/LoadAccountMaster',
'Account Master','account_account_master');"> <img src="layouts/static/image/micons/account_master.png">Account Master</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/AccountsDashboard',
'Accounts Dashboard','accounts_dashboard');"> <img src="layouts/static/image/micons/accounts_dashboard.png">Accounts Dashboard</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/AccountSettings',
'Account Settings','accounts_account_settings');"> <img src="layouts/static/image/micons/account_settings.png">Account Settings</a>
我正在尝试点击帐户组,其中 dashboard.Neither 个帐户正在接收 clicks.Tried 此代码但失败了。
List<WebElement> submenus=driver.findElements(By.xpath("//li[@id='one1']//li//a"));
for (WebElement submenu: submenus) {
System.out.println("values of each submodule :
"+submenu.getAttribute("innerHTML"));
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
if (submenu.getAttribute("innerHTML").contains("Accounts Dashboard")) {
submenu.click();
break;
}
单击“帐户仪表板”
javascript:void(0);
在帐户仪表板的 href 中 returns 未定义。当试图点击这样的 link 时,会执行点击,并且没有方法 return 值是 obtained.This 给人的印象是没有执行点击。使用
JavascriptExecutor jsexec = (JavascriptExecutor) driver;
jsexec.executeScript("arguments[0].click();", submenu);
而不是submenu.click();
单击帐户组
Selenium 单击此 link 并且 href #one1 附加到 URL 以确认单击已执行。
这是我正在处理的代码 on.I 我正在尝试点击子菜单。
<ul class="accordion">
<li id="one1" class="files">
<a href="#one1">Accounts</a>
<ul class="sub-menu">
<li>
<a href="#one1" onClick="loadTabv2('accounts/LoadAccountGroupMaster',
'Account Group','accounts_account_group');"><img src="layouts/static/image/micons/account_group.png">Account Group</a>
<a href="#one1" onClick="loadTabv2('accounts/AccountingPeriod',
'Accounting Period','account_accounting_period');"><img src="layouts/static/image/micons/accounting_period.png">Accounting Period</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/LoadAccountMaster',
'Account Master','account_account_master');"> <img src="layouts/static/image/micons/account_master.png">Account Master</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/AccountsDashboard',
'Accounts Dashboard','accounts_dashboard');"> <img src="layouts/static/image/micons/accounts_dashboard.png">Accounts Dashboard</a>
<a href="javascript:void(0);" onClick="loadTab('accounts/AccountSettings',
'Account Settings','accounts_account_settings');"> <img src="layouts/static/image/micons/account_settings.png">Account Settings</a>
我正在尝试点击帐户组,其中 dashboard.Neither 个帐户正在接收 clicks.Tried 此代码但失败了。
List<WebElement> submenus=driver.findElements(By.xpath("//li[@id='one1']//li//a"));
for (WebElement submenu: submenus) {
System.out.println("values of each submodule :
"+submenu.getAttribute("innerHTML"));
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
if (submenu.getAttribute("innerHTML").contains("Accounts Dashboard")) {
submenu.click();
break;
}
单击“帐户仪表板”
javascript:void(0);
在帐户仪表板的 href 中 returns 未定义。当试图点击这样的 link 时,会执行点击,并且没有方法 return 值是 obtained.This 给人的印象是没有执行点击。使用JavascriptExecutor jsexec = (JavascriptExecutor) driver; jsexec.executeScript("arguments[0].click();", submenu);
而不是
submenu.click();
单击帐户组
Selenium 单击此 link 并且 href #one1 附加到 URL 以确认单击已执行。