- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在检查页面中的单选按钮。
我正在查找页面上的所有按钮,如果它们不正确,我想单击它们。
如果结果是假的,我实际上很难点击它。
我怎样才能点击它?
我已附上我当前的代码和页面 html。
List<WebElement> elementxb1 = driver.findElements(By.xpath("//input[@name='contractPeriod']"));
for(int i11 = 0 ; i11< elementxb1.size() ; i11++){
boolean vapval2b = elementxb1.get(i11).findElement(By.xpath("//input[@name='contractPeriod']")).isSelected();
if(vapval2b)
{
System.out.println("Yes Button is selected ? : " + vapval2b);
}
else
{
System.out.println("No Button is not selected, click on it. ? :" + vapval2b);
// click on the radio button here.
}
}
<html ng-app="dan" class="ng-scope"><head><style type="text/css">[uib-typeahead-popup].c-dropdown-menu{display:block;visibility:visible;opacity:1;}</style><style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<base href="/">
<title></title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="/build/styles.css?v=0.1">
<!-- Prefetch DNS for all other external assets -->
<link rel="dns-prefetch" href="//ajax.googleapis.com">
</head>
<body class="u-scroll-y ng-scope" ng-controller="CoreController as cc" style="">
<!-- Begin Alerts -->
<div class="c-animate c-animate--show u-pos-f-t ng-hide" ng-show="global.alerts.length">
<div class="o-grid">
<div class="o-grid__row">
<div class="o-grid__col-lg-8 o-grid__col-lg-offset-2 u-pt-md">
<!-- ngRepeat: alert in global.alerts -->
</div>
</div>
</div>
</div>
<!-- End Alerts -->
<div class="o-grid-fluid u-h-100 u-pl-0">
<div class="o-grid__row u-ml-0 u-h-100">
<div class="c-loader ng-hide" ng-show="loadingHome">
<div class="c-loader-spinner u-center-block"></div>
</div>
<!-- ngIf: global.loggedIn --><nav class="o-grid__col-xl-2 o-grid__col-lg-3 o-grid__col-xs-4 u-p-0 c-card__block u-h-100 u-shadowed u-pos-f-t ng-scope" ng-if="global.loggedIn" style="">
<div class="o-layout-table u-h-100">
<div class="o-layout-table__row">
<div class="u-p u-bb">
<a href="#/home">
<img src="/images/cars-logo-landscape.svg" alt="Car logo">
</a>
</div>
</div>
<div class="o-list-group u-text-90">
<a href="#/home" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/home') }" style="">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>Home
</div>
</a>
<a href="#/starting-questions" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/starting-questions'), 'u-disabled' : !cc.answers() }" style="">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>Starting Questions
</div>
</a>
<a href="#/recommendations" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/recommendations'), 'u-disabled' : !cc.questions() }" style="">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>Recommendations
</div>
</a>
<a href="#/purchase-decisions" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/purchase-decisions'), 'u-disabled' : !cc.recommend() }" style="">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>Purchase Decisions
</div>
</a>
<a href="#/finance-contract-conclusion-form" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize u-text-primary u-bg-faded" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/finance-contract-conclusion-form') }" style="">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>FCC Form
</div>
</a>
<a href="#/finish" class="o-list-group__item u-pl-md u-py-sm u-text-80 u-text-capitalize" ng-class="{ 'u-text-primary u-bg-faded u-text-primary': cc.isActive('/finish') }">
<div class="u-py-sm">
<i class="i-icon i-icon--angle-right u-text-100 u-pull-right"></i>Finish and sign
</div>
</a>
<div class="o-list-group__item u-w-100 u-bt u-bg-faded u-text-80 u-text-capitalize u-pos-a-b u-push-up-btn-lg u-pl-md u-pb-sm">
<div class="u-py-sm u-bb u-mb-sm">
<i class="i-icon i-icon--file u-text-100 u-pull-right"></i>Documents
</div>
<!-- ngIf: cc.forms.recommendVap --><div class="u-mb-sm u-pointer ng-scope" ng-if="cc.forms.recommendVap" ng-click="cc.previewForms()" style=""><i class="i-icon i-icon--pdf u-text-100 u-pr-sm"></i> VAP Recommendations</div><!-- end ngIf: cc.forms.recommendVap -->
<!-- ngIf: cc.forms.recommendWarranty --><div class="u-mb-sm u-pointer ng-scope" ng-if="cc.forms.recommendWarranty" ng-click="cc.previewForms()"><i class="i-icon i-icon--pdf u-text-100 u-pr-sm"></i> Warranty Recommendations</div><!-- end ngIf: cc.forms.recommendWarranty -->
<!-- ngIf: cc.forms.vapTerms --><div class="u-mb-sm u-pointer ng-scope" ng-if="cc.forms.vapTerms" ng-click="cc.previewForms()"><i class="i-icon i-icon--pdf u-text-100 u-pr-sm"></i> VAP key facts leaflet</div><!-- end ngIf: cc.forms.vapTerms -->
<!-- ngIf: cc.forms.purchaseVap --><div class="u-mb-sm u-pointer ng-scope" ng-if="cc.forms.purchaseVap" ng-click="cc.previewForms()" style=""><i class="i-icon i-icon--pdf u-text-100 u-pr-sm"></i> VAP Purchase Decisions</div><!-- end ngIf: cc.forms.purchaseVap -->
<!-- ngIf: cc.forms.purchaseWarranty --><div class="u-mb-sm u-pointer ng-scope" ng-if="cc.forms.purchaseWarranty" ng-click="cc.previewForms()"><i class="i-icon i-icon--pdf u-text-100 u-pr-sm"></i> Warranty Purchase Decisions</div><!-- end ngIf: cc.forms.purchaseWarranty -->
<!-- ngIf: cc.forms.optOut -->
<!-- ngIf: cc.forms.fcc -->
</div>
<!-- Bottom -->
<a class="o-list-group__item u-bt u-pos-a-b" ng-click="cc.optOut(); cc.utils.audit('opt_out')">
<label class="c-option u-px u-py-sm u-text-capitalize u-clearfix u-mb-0">
<input type="checkbox" name="" value="" ng-model="optout" class="ng-pristine ng-untouched ng-valid">
<i class="i-icon i-icon--close u-text-100 u-pull-right"></i>opt out
</label>
</a>
<!-- <a href="#/settings" class="o-list-group__item u-bt u-pos-a-b">
<label class="c-option u-px u-py-sm u-text-capitalize u-clearfix u-mb-0">
<input type="checkbox" name="" value="{{ $index }}"
ng-model="global.vap">
<i class="i-icon i-icon--cog u-text-100 u-pull-right"></i>Settings
</label>
</a> -->
</div>
</div>
</nav><!-- end ngIf: global.loggedIn -->
<div class="u-p-0 u-h-100 o-grid__col-xl-10 o-grid__col-lg-9 o-grid__col-xs-8 u-pull-right" ng-class="{ 'o-grid__col-xl-10 o-grid__col-lg-9 o-grid__col-xs-8 u-pull-right' : global.loggedIn }" style="">
<!-- ngIf: global.loggedIn --><header class="o-layout-table__row u-bg-primary u-shadowed u-clearfix u-px ng-scope" ng-if="global.loggedIn" style="">
<div class="u-p-sm u-text-left u-pull-left ng-binding">
<i class="i-icon i-icon--calendar"></i> Friday, January 5, 2018
</div>
<a href="#" class="c-btn c-btn--primary u-pull-right u-pull-right" ng-click="cc.signOut(); cc.utils.audit('sign_out')">
<i class="i-icon i-icon--user-minus"></i> Sign out
</a>
</header><!-- end ngIf: global.loggedIn -->
<main class="o-view-container">
<div class="o-grid-fluid u-py-md">
<div class="o-grid__row">
<!-- ngView: --><div class="c-animate c-animate--view-slide-in-right c-animate--view-slide-out-right ng-scope" ng-view="" style=""><div class="o-grid__col-md-10 o-grid__col-xl-8 o-grid__col-xl-offset-2 o-grid__col-md-offset-1 ng-scope"><div class="u-mb-lg u-text-center"><h1 class="u-text-bold">Finance Contract Conclusion Form</h1></div><!-- Previously sent --><!-- ngIf: fcc.prevFcc() --><!-- Interest calculator and other info --><!-- ngIf: fcc.fccAlone && !fcc.prevFcc() --><!-- Form --><!-- ngIf: !fcc.prevFcc() --><div class="o-media c-card c-card__block u-shadowed u-mb-lg ng-scope" ng-if="!fcc.prevFcc()"><form name="fccForm" ng-submit="fccForm.$valid" class="ng-pristine ng-invalid ng-invalid-required"><div class="c-form-group"><label class="c-form-control-label u-p-0 u-w-100">Within 24 hour Pre Contract Review Period:</label><label class="c-option c-option--right u-px u-py-sm u-clearfix" ng-click="cc.utils.audit('fcc_24_hour_yes')"><input type="radio" required="" ng-model="fcc.values.contractPeriod" value="Yes" name="contractPeriod" class="ng-pristine ng-untouched ng-invalid ng-invalid-required"> <i class="c-option__radio"></i>Yes</label><label class="c-option c-option--right u-px u-py-sm u-clearfix" ng-click="cc.utils.audit('fcc_24_hour_no')"><input type="radio" required="" ng-model="fcc.values.contractPeriod" value="No" name="contractPeriod" class="ng-pristine ng-untouched ng-invalid ng-invalid-required"> <i class="c-option__radio"></i>No</label></div><div class="o-grid__col-md-6 u-mt"><input type="submit" class="c-btn c-btn--primary c-btn--block u-pull-right" value="Complete and Preview" ng-disabled="fccForm.$invalid" ng-click="fccForm.$valid && fcc.previewPDF(fccForm.$valid); cc.utils.audit('fcc_complete')" disabled="disabled"></div><div class="o-grid__col-md-6 u-mt"><input type="submit" class="c-btn c-btn--primary c-btn--block u-pull-right" value="Skip" ng-click="fcc.skipPDF(); cc.utils.audit('fcc_skip')"></div></form></div><!-- end ngIf: !fcc.prevFcc() --></div></div>
</div>
</div>
</main>
</div>
</div>
</div>
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="./build/app.js?v=2.13" defer=""></script>
</body> <xpather id="xpather"> <form id="xpather-form"> <input id="xpather-xpath" type="text" placeholder="enter XPath…" autocomplete="off" spellcheck="false"> </form> <xpather id="xpather-result"></xpather> <xpather id="xpather-sidebar-toggler"></xpather> </xpather> <xpather id="xpather-sidebar"> <xpather id="xpather-sidebar-spacer"></xpather> <xpather id="xpather-sidebar-entries"></xpather> </xpather></html>
最佳答案
试试这个:
List<WebElement> elementxb1 = driver.findElements(By.xpath("//input[@name='contractPeriod']"));
for (WebElement element : elementxb1){
boolean vapval2b = element.isSelected();
if(vapval2b)
{
System.out.println("Yes Button is selected ? : " + vapval2b);
}
else
{
System.out.println("No Button is not selected, click on it. ? :" + vapval2b);
// click on the radio button here.
if(element.isDisplayed())
element.click();
else{((JavascriptExecutor)driver).executeScript("arguments[0].click();",element);
}
}
}
编辑1:
List<WebElement> elementxb1 = driver.findElements(By.xpath("//input[@name='contractPeriod']"));
for(int i11 = 0 ; i11< elementxb1.size() ; i11++){
elem = elementxb1.get(i11).findElement(By.xpath("//input[@name='contractPeriod']"));
boolean vapval2b = elem.isSelected();
if(vapval2b)
{
System.out.println("Yes Button is selected ? : " + vapval2b);
}
else
{
System.out.println("No Button is not selected, click on it. ? :" + vapval2b);
// click on the radio button here.
if(elem.isDisplayed())
elem.click();
else{((JavascriptExecutor)driver).executeScript("arguments[0].click();",elem);
}
}
关于java - boolean 检查后单击单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48110880/
所以我有这个 javascript 片段,它有两个按钮可以进入全屏,一个按钮可以退出全屏。我想做到这一点,如果我不在全屏模式下,按钮会显示转到全屏模式,而当我处于全屏模式时,按钮会显示退出全屏模式..
我在自定义控件中添加了一个新属性作为可扩展属性,例如属性网格中的字体属性。在 Windows 窗体应用程序项目中使用我的自定义控件后,我在属性网格中看到一个省略号 (…) 按钮,如字体属性的“…”按钮
我在自定义控件中添加了一个新属性作为可扩展属性,例如属性网格中的字体属性。在 Windows 窗体应用程序项目中使用我的自定义控件后,我在属性网格中看到一个省略号 (…) 按钮,如字体属性的“…”按钮
我尝试将 Twitter 上的“Tweet Me”按钮 ( http://twitter.com/goodies/tweetbutton ) 添加到我的网站。然而,每当按下按钮时,我都会收到此 Jav
我试图在我的文本区域中获取一个按钮值,如果我使用 则工作正常但如果我使用那么它就不起作用了。你能找出问题所在吗? HTML 1 2 3 4 JavaScript $(document).read
我的 C# Winform 面板中有一堆文本框。每行文本框的命名如下: tb1 tbNickName1 comboBox1 tb2 tbNickName2 comboBox2 tb3 tbNickNa
我有一个表单,其中过滤器下方有按钮(应用过滤器和清除过滤器),我试图在单击“应用”按钮时显示“清除”,并在单击“清除”按钮时隐藏“清除”按钮。 下面的代码(如果我的表有的话):
excel 按钮正在工作,但是当我添加 pdf 按钮时,它添加仅显示 pdf 按钮 excel 按钮在 pdf 按钮添加后隐藏 $(document).ready(function() { $
我想创建一个 div 作为标题并分成 3 列,并按以下顺序在其中放置 2 个按钮和一个标题:Button1(左位) Title(居中) Button2(右位) 这是我为这个 div 编写的代码:
仅当选中所有框时才应禁用“允许”按钮。我该怎么做?我已经完成了 HTML 部分,如下所示。如何执行其中的逻辑部分?即使未选中一个复选框,也应禁用“允许”按钮
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
如您所知,您可以使用 2 种方法在 HTML5 中呈现按钮: 使用 void 元素 或 如果您需要内容,请使用 元素(不是空元素)。 在JSF2中,有2种方式生成按钮;与UICommand或 UIOu
我尝试根据表单元素的更改禁用/启用保存按钮。但是,当通过弹出按钮选择更改隐藏输入字段值时,保存按钮不受影响。 下面是我的代码。我正在尝试序列化旧的表单值并与更改后的表单值进行比较。但我猜隐藏的字段值无
我有用于在消息(电子邮件、短信)上输入内容的 EditText。我希望在单击 ActionDone 按钮时立即发布消息。我为此使用以下代码: message.setOnEditorActionList
我的 Android 应用程序中有一堆 EditText,每个都将 InputMethod 设置为 numberSigned。我的目标设备没有硬件键盘,而是使用软件键盘输入数字。 Android 将输
我无法以编程方式隐藏弧形菜单中的 fab 按钮。我正在使用https://github.com/saurabharora90/MaterialArcMenu在我的代码中。如何在Java中以编程方式隐藏
我已经看到这在其他类型的对话框窗口中是可能的,例如“showConfirmDialog”,其中可以指定按钮的数量及其名称;但是使用“showInputDialog”时是否可以实现相同的功能?我似乎无法
相同的按钮用于激活和停用。第一次,当代码运行按钮单击并成功“停用”时。但第二次,代码无法找到该元素。第一个案例按钮位于第二个“a”标签中,然后停用第一个“a”标签中的按钮。 案例1: Edit
是否可以将按钮的 onclick 操作设置为 JavaScript 变量?这个想法是我们用 JavaScript 控制一个表。每当点击该表的一行时,我们就会更新一个 JavaScript 变量。该 v
我想创建一个按钮,它包含左侧的文本和右侧的复选框(或任何其他组件)。我怎样才能做到这一点? 我发现我可以制作自己的 View extends Button,但是如果可以的话我应该如何实现 onDraw
我是一名优秀的程序员,十分优秀!