Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
<input id="actionQty_8445901" style="position:absolute" onclick="AddMeToCart(this)" type="checkbox">
select multiple check box
<input id="actionQty_8445901" style="position:absolute" onclick="AddMeToCart(this)" type="checkbox">
'//input[starts-with(#id,'actionQty_')][1]'
am trying this but its working for one check box only
You can use this xpath to select multiple checkboxes
//input[contains(#id,'actionQty')]
and also use findElements() method to select it
List<WebElement> checkElements= driver.findElements(By.xpath("//input[contains(#id,'actionQty')]"));
for (WebElement check_elem: checkElements) {
check_elem.click();
}
Xpath of the element will be like
//input[starts-with(#id, 'actionQty_')]
then you need to find number of checkbox and click element withinloop
Then you can get all the checkbox
List<WebElement> allElements = driver.findElements(By.xpath(" //input[starts-with(#id, 'actionQty_')]"));
for (WebElement element: allElements) {
element.click();
//do your operation
}
Hope it will work
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
how do you input 2 props in one line in VUEJS?
Im using vuejs 2 and element UI.
<el-table-column prop="`(creator_name + creator_username)`" label="Founder"></el-table-column>
The output should be
test(09123567)
in Vue, you can passing the variable as props with colon as prefix
in your case:
<el-table-column :prop="`${creator_name} ${creator_username})`" label="Founder"></el-table-column>
in Vue you have to put : before a property to dynamically assign value to it. in your case it should be
<el-table-column :prop="creator_name + creator_username" label="Founder"></el-table-column>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I provided below HTML code snippets can you help me how to write a test case using html web element "searchInput".
This my HTML Elements:
<div _ngcontent-c5="" class="input-group input-group-lg">
<input _ngcontent-c5="" class="form-control ng-valid ng-dirty ng touched" formcontrolname="searchInput" name="searchInput" placeholder="Please search here...?" type="text" ng-reflect-name="searchInput">
<div _ngcontent-c5="" class="input-group-append">
<button _ngcontent-c5="" class="btn btn-bxc-black px-2"type="submit">
<mat-icon _ngcontent-c5="" class="mat-icon material-icons" role="img" aria-hidden="true">search</mat-icon>
</button></div></div>
${search_box}= Get Element Attribute css=[name="searchInput"] value
or
${search_box}= Get Element Attribute css=[name="searchInput"]#value
have you tried this?
You need to import selenium2Library fir this.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am currently working on a project where the xpath of the elements changes continuously. At the UI display level there is not much visible change in UI, however the DOM elements changes continuously.
I am thinking of a better approach to handle failures in test case due to minor changes in DOM structure. I am currently using Selenium with TestNg framework for UI Automation Testing.
Any suggestions or directions on alternate approach would be helpful.
Are you following the orders of locators suggested by Selenium contributors: if not then please follow this order :
ID
name
className
linkText
partialLinkText
tagName
cssSelector
XPath.
Note : Most of the time a cssSelector can replace Xpath, However Xpath has its own advantages which cssSelector do not provide.
For more reference you can go through this SO Link : Css vs Xpath
My suggestion would be:
1. Try using different locators for particular element[https://api.jquery.com/multiple-selector/]
something like selector1, selector2, selectorN. If selector1 is not available in DOM, control will not throw an error instead, it will search selector2 and so on
2. Use Explicit waits
I use By.CSS selectors rather than by xpath, as these are less prone to changes in the DOM.
So for this example dom:
<div class="smc-login-container">
<form role="form" action="/login.html" method="POST" name="login" class="ng-pristine ng-valid">
<!-- Username -->
<label for="username">User ID:</label>
<input type="text" class="smc-login-control aftLoginUsernameField" id="username" name="username">
<!-- Password -->
<label for="password">Password:</label>
<input type="password" class="smc-login-control aftLoginPasswordField" id="password" name="password">
<!-- Cross site scripting token -->
<input type="hidden" id="_csrf" name="_csrf" value="efaa05c4-77a8-443d-9484-51e8c9795c28">
<!-- Sign In Button -->
<button id="signIn" class="btn btn-lg btn-block smc-login-button aftLoginSignInButton">
Sign In
</button>
</form>
These selectors work:
Example 1. Find Button, element type and class
WebElement element = webDriver.findElement(By.cssSelector("button.btn"));
Example 2. Find Button, direct child rather than descendent
Uses full DOM and thus form element:
WebElement element = webDriver.findElement(By.cssSelector("div > form > button"));
Doesn't use form element:
WebElement element = webDriver.findElement(By.cssSelector("div button"));
Example 3. Find Input following the username label, attribute with value then it’s sibling (+)
WebElement element = webDriver.findElement(By.cssSelector("label[for='username'] + input"));
Example 4. Find Password input and Button, OR’d (comma) returning more than one element
List<WebElement> elements;
elements = webDriver.findElements(By.cssSelector("input.smc-login-control.aftLoginPasswordField , .btn"));
elements.get(0).sendKeys("my password");
elements.get(1).click();
Example 5. Find username input, has class attribute, but not attribute name = ‘password’:
WebElement element = webDriver.findElements(By.cssSelector("input[class]:not([name='password'])"));
Another thing I do is use a more generic pattern, which finds multiple items. I've found the items are always found in the same sequence and thus I can access the one I want by just using the array index (like in example 4).
Finally, if the DOM has dynamic values I've found that I can use a specific stable pattern to find a parent element which has the same dynamic value, thus extract it and then reuse it to find the other element I actually want.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Refer this firepath :
.//*[#id='gwt-uid-20138']
HTML :
<input id="gwt-uid-20138" type="checkbox" value="on" tabindex="0">
Note: this id value gets changed.
If id is changing, maybe try to find checkbox using label next to this checkbox?
Try something like this:
/label[text()="test"]/preceding-sibling::input
If selector of your checkbox keeps on changing you need to identify it with the property which is always constant and unique.
From your example you can see that gwt-uid- part is always constant, you can use the same to identify the element.
driver.findElement(By.xpath("//input[starts-with(#id, 'gwt-uid-')]"));
To find the checkbox element you have to take help of the id attribute. But as you can see the id attribute is dynamic, so we have to make our Locator Strategy dynamic. Now if you observe the id attribute closely you will observe that the gwt-uid- part is constant and only the remaining part i.e. 20138 is dynamic. So we can use the starts-with() method for the dynamic id and to identify the checkbox uniquely we will also include the type attribute while constructing the locator. So to find the checkbox element you can use the following line of code :
Java :
WebElement element = driver.findElement(By.xpath("//input[starts-with(#id,'gwt-uid-') and #type='checkbox']"));
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm new to Vue! I want to build a simple select field with value:
"0" => "No age limit", 6 ->90
So, I would like to build 6 to 90 with a v-for, but I don't know exactly how to do it, and still to have the initial "no age limit"
Any idea how to do it???
It shoud be something like this:
<body>
<select>
<option value="0">No age limit</option>
<option :value="n+6" v-for="n in 85">{{n+6}}</option>
</select>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.21/vue.min.js"></script>
<script>
new Vue({
el: 'body'
})
</script>
</body>