我想点击“打开设备访问”按钮但是当我点击手风琴时,不会显示“打开设备访问”按钮。 我认为JavaScript不活动,因为“display none”和“display block”之间的传输不存在。点击手风琴后,“打开设备访问”按钮不可见。
HTML code:
<div id="device_hmi_content_22">
<div id="accordion_device_hmi_22" class="accordion">
<h2 class="accHeadline accHeadlineClosed">Device Access</h2>
<div class="accContent accContentClosed" style="display: none;">
<div class="submit">
<input type="button" onclick="onOpenSessionClick()" value="Open device access">
</div>
</div>
JavaScript代码:
driver.findElement(By.xpath("//a[@href='/mybox/devices/satellite.php']")).click();
Thread.sleep(5000);
driver.findElement(By.id("device_hmi_content_22")).click();
WebElement element2 = driver.findElement(By.xpath("//input[@value='Open device access']"));
if (isElementPresent(By.xpath("//input[@value='Open device access']")))
{
driver.findElement(By.xpath("//input[@value='Open device access']")).click();
答案 0 :(得分:0)
可能您可以使用js executor来显示这些按钮:
driver.findElement(By.xpath("//a[@href='/mybox/devices/satellite.php']")).click();
Thread.sleep(5000);
driver.findElement(By.id("device_hmi_content_22")).click();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.document.getElementsByClassName('accContent accContentClosed')[0].style.display='block';");
WebElement element2 = driver.findElement(By.xpath("//input[@value='Open device access']"));
if ( isElementPresent(By.xpath("//input[@value='Open device access']")) )
{
driver.findElement(By.xpath("//input[@value='Open device access']")).click();