I have been trying to "sendkeys" to a IntegerSpinnerField but it is not working. The IntegerSpinnerField has a id but I can't use the "sendkeys" on it. I opened up the html the ID is there but the IntegerSpinnerField is 3 widgets in 1. So is there anyway i can give an id to the 3 widgets that make up the IntegerSpinnerField.
html-code
<div __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" id="maximumfrequencySpinnerField" class="GJCAMDBBOPB" title="Enter an maximum frequency value within the allowable range. The allowed range is 776 to 787 MHz" style="width: 100px;"><div style="width: 100px;" class="GJCAMDBBAW"><table width="100%" cellpadding="0" cellspacing="0"><tbody><tr><td><input style="width: 75px;" type="text" value="" class="GJCAMDBBCV GJCAMDBBJV" id="x-auto-229-input" tabindex="0" disabled=""></td><td><div class="GJCAMDBBKV"></div><div class="GJCAMDBBNV"></div></td></tr></tbody></table></div></div>
Id of the textfield which is autogenerated
Don't go with id's for ExtJs Applications those were dynamically generated at runtime and prone to change everytime.So you have to write a relative xpath for every element.And ExtJS elements follow some pattern So you have to write xpaths for that and you can reuse them.
Refer any-suggestions-for-testing-extjs-code-in-a-browser-preferably-with-selenium
For your case and for most input element you can find it using label.The immediate input of the label might be the element you are looking for
I have tested the spinner field named Revenue %: in this demo site using the following xpath
//label[text()='Revenue %:']//following::input
The script for the above site.Hope it helps
WebDriver driver = new FirefoxDriver();
driver.get("https://www.sencha.com/examples/#ExamplePlace:dashboard");
WebElement element=driver.findElement(By.xpath("//label[text()='Revenue %:']//following::input"));
element.clear();
element.sendKeys("67.67");
Related
I'm using Liferay AutoFields for first time, everything's ok, but the problem is that I can't set a limit in the "clone" event to get up to six fields only, and seems like documentation not exists, just found examples.
I'm using Liferay 7.0, this my aui:form:
<aui:form action="<%= addURL %>" name="<portlet:namespace />addForm">
<div id="auto-fields-container">
<div class="lfr-form-row lfr-form-row-inline sku-input-container">
<aui:input name="skuIdSave" label="Registrar SKU" helpMessage="Se consultará el SKU ingresado"></aui:input>
</div>
</div>
<aui:button-row>
<aui:button type="submit"></aui:button>
</aui:button-row></aui:form>
and this is my Liferay Auto Fields code fragment:
new Liferay.AutoFields({
contentBox: '#auto-fields-container',
fieldIndexes: '<portlet:namespace />rowIndexes',
on: {
'clone': function(event) {
console.log('Clone event');
console.log(event);
console.log('Cloned node');
console.log(event.row);
},
'delete': function(event) {
console.log('Delete event');
console.log(event);
}
},
sortable: true,
sortableHandle: '.lfr-form-row'
}).render();
There is a native way in the plugin to set a repetition limit? Or only can be done by the clone "event" logic? Because I found the way to get the number of fields by clicking the add and remove buttons, and I tried something like this, without exit:
if(AUI().all('.sku-input-container:visible').size() >= 6)
delete(event);
Although I found a way (with JQuery) to delete the created row when the number of fields is the limit I want, I guess it could affects to the "undomanager" logic ("undomanager" renders by default as a div in the form)
Undomanager:
<div id="yui_patched_v3_18_1_1_1665078696121_520" class="yui3-widget component undomanager"><div id="yui_patched_v3_18_1_1_1665078696121_522" class="undomanager-content helper-clearfix alert alert-info lfr-undo-queue"><a class="lfr-action-undo" href="javascript:;">Deshacer <span class="lfr-items-left" id="yui_patched_v3_18_1_1_1665078696121_2775">(2)</span></a><a class="lfr-action-clear" href="javascript:;">Eliminar el historial</a></div></div>
Many thanks in advance.
I am trying to use xpath to find input in a textbox a card number but the id is dynamic and class contains multiple hyphens , its not able to find the xpath i have tried for the given html
<div class="a-section a-spacing-none add-cc-number
<input type="tel" id="pp-XQAs3V-15" autocomplete="off" name="addCreditCardNumber" class="a-input-text a-form-normal a-width-medium" data-testid="pmts-account-Number">
</div>
</div>
When i use chropath it says It might be child of svg/pseudo element/comment/iframe from different src. Currently ChroPath doesn't support for them.
Xpath tried:
//input[contains(name(),'ppw-accountHolderName')]
tried with ancestor sibling too.
name() is an XPath function to get te name of een element.
If the input has this name addCreditCardNumber use this:
//input[#name='addCreditCardNumber']
I need to verify whether placeholder/helper text is displayed for a field.
In this example it is Min. $50.00
I don't see any placeholder/helper text attribute defined inside the div tags.
My field looks like . Displayed amount (in this example $50.00) is dynamic.
Code for the above field looks like
<div class="unit" style="padding-left:32px;">
<input id="Amount" type="text" class="inputAlign optionalHintText" size="18" maxlength="30"/>
<div id="sharesValueForPercent" class="TextMd"></div>
</div>
I tried different ways to get the text (Min$50.00). Can someone help me on this. Appreciate your response.
To extract the placeholder text i.e. $50.00 you can use either of the following Locator Strategies:
Using cssSelector:
System.out.println(driver.findElement(By.cssSelector("input.inputAlign.optionalHintText#Amount")).getAttribute("value"));
Using xpath:
System.out.println(driver.findElement(By.xpath("//input[#class='inputAlign optionalHintText' and #id='Amount']")).getAttribute("value"));
<table id="usersForm:mainTable:n" class="extdt-table-layout res-table" cellspacing="0" cellpadding="0" border="0" width="100%;" style="">
<colgroup id="usersForm:mainTable:colgroup:body">
<tbody id="usersForm:mainTable:tb">
<tr id="usersForm:mainTable:n:0" class="extdt-firstrow rich-extdt-firstrow extdt-row-selected rich-sdt-row-selected res-table-selected" onmousedown="handleMouseClick(event)">
<td id="usersForm:mainTable:1:name" class="extdt-cell rich-extdt-cell">
<div class="extdt-cell-div">
<div onmouseup="if (showMenu(this)) {document.lkjasdf = event; selectContextMenu('ENTTUSER','MbUsersSearch');}">
<span title="ADMIN" onmouseup="if(!rightButton && isSelectedRow(this,rightButton) && false && !disableContext) {setDisableContext(true); beforePrepareDefaultAction('ENTTUSER','MbUsersSearch');}">ADMIN</span>
Using htmlelements pattern, i want get value from table, ie verify that table contains value "ADMIN".
In htmlelements can able work with tables "from the box". I wrote:
import ru.yandex.qatools.htmlelements.element.Table;
public class MainTableForm extends HtmlElement {
#FindBy(id = "usersForm:mainTable:n")
private Table table;
}
Then I do not know which method helps to get the value.
You can use List<List<String>> getRowsAsString() method to get all the values from your table. Then just check this collection with hamcrest matcher. So the final code will be pretty simple:
assertThat(table.getRowsAsString(), contains(contains(equalTo("ADMIN"))));
You can do this
WebElement adminSpan = driver.findElement(By.cssSelector("#usersForm:mainTable:n span[title='ADMIN']"));
System.out.println(adminSpan.getText().trim());
I added the TABLE id just in case there is more than one of these admin SPANs. The CSS selector reads as find an element with an id (#) of usersForm:mainTable:n that has a descendant () SPAN with the title of ADMIN.
You may or may not need to trim(). I've gotten to the point where I just always trim() because it's easy and it saves me time finding and adding it later when I find out I needed it but didn't realize it. :)
Try to find out by installing firepath
find out the path by firepath
I am trying to find an element with Selenium and Java, the problem is that the element's id, class, and name always increment so I am not able to find it with selenium. Below is what I am currently trying:
WebElement field = driver.findElement(By.xpath("//input[contains(#linkText, 'Broadcast copy')]"));
In my html file these are the attributes that keeps changing:
id="files[%2Fopt%240%2Frules%2F%2F000102%2.xml][%2Fcluster%2Fname]"
name="files[%2Fopt%240%2Frules%2F%2F000102%2.xml][%2Fcluster%2Fname]"
value="copy (Cluster 102)"
Entire html
<tbody>
<tr class='rowOdd'>
<td><b>Name</b></td>
<td> <input type='text' data-validation='required validate-name-unique validate-name-not-empty' size='65' id='files[%2Fopt%240%2Frules%2F%2F000102%2Fcluster.xml][%2Fcluster%2Fname]' name='files[%2Fopt%240%2Frules%2F%2F000102%2Fcluster.xml][%2Fcluster%2Fname]' value='copy (Cluster 102)' /> </td>
These always increment and I have no access to the html file to change anything. So my question is how can I find this input element? Thanks in advance.
UPDATE
I get the error:
Unable to locate element:{"method":"id", "selector":"files[.*][.*]"}
I believe the xpath you are using is incorrect. Use
//input[contains(text(), 'Broadcast copy')]
instead of
//input[contains(#linkText, 'Broadcast copy')]
According to the html you have provide the following should work as well
//body[contains(.,'Name')]//input
Try this..
In case "copy (Cluster" text in value attribute is not changing, then you can try below xpath:-
//body[contains(.,'Name')]//input[contains(#value,'copy (Cluster')]
Since the attributes of id, class, and css were constantly changing, 'data-validation' was one that stayed the same all the time. So the code below worked for me.
driver.findElement(By.xpath("//input[#data-validation='required validate-name-unique validate-name-not-empty']"));