Since clean 8.5.3 Domino has problem with localized numbers with space as thousand separators, I decided to switch to djCurrencyTextBox. But as don't want to display fractional part, I'm struggling with it too. Even on 9.0.1 test server.
If I create simple field using:
<xe:djCurrencyTextBox id="djCurrencyTextBox1" value="#{document1.currency}">
<xe:this.constraints>
<xe:djNumberConstraints fractional="false">
</xe:djNumberConstraints>
</xe:this.constraints>
</xe:djCurrencyTextBox>
It does not recognize any number entered. ( I get message that value is not valid even when I enter just 1)
When add it as dojo attribute directly, it works as expected
<xe:djCurrencyTextBox id = "djCurrencyTextBox1"
value ="#{document1.currency}" >
<xe:this.dojoAttributes>
<xp:dojoAttribute name ="data-dojo-props"
value ="constraints:{fractional:false}" >
</xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djCurrencyTextBox >
Any ideas what can cause the issue?
This is a known issue that is not fixed in 9.0.1
Using the first example above, no matter what value you set on the fractional constraint (enable/disable/auto/true/false), the textbox only ever accepts a value with fractional part included (e.g. 567.89), which is incorrect for disable & false values. The second example works as expected with fractional set to true or false.
This is because, looking at the page source, the html output for the first example is:
<input dojoType="dijit.form.CurrencyTextBox" constraints="{"fractional":"false"}" id="view:_id1:djCurrencyTextBox1" name="view:_id1:djCurrencyTextBox1">
The """ parts should not be included in the constraints.
Whereas with the 2nd example, there is no such issue:
<input dojoType="dijit.form.CurrencyTextBox" data-dojo-props="constraints:{fractional:false}" id="view:_id1:djCurrencyTextBox2" name="view:_id1:djCurrencyTextBox2">
As this has not yet been fixed in 9.0.1, all you can do is utilise the workaround that you have posted for the time being.
UPDATE: The fix for this issue is in Release 9 of the v901 XPages Extension Library on OpenNTF
Related
I have to find xpath for a textbox using id attribute. However, a portion of the attribute keeps changing every time I login to the application which I'm automating and the remaining portion remains unchanged. PFB example -
Attribute ------> id="StringJob_value_1102199569"
Here, the numeric value changes during every login and the portion "StringJob_value" remains unchanged.
Hence, is there any way in selenium to only use the constant portion of the attribute to identify the web element(Text Box)?
Try the following xpath:
//*[contains(#id, 'StringJob_value_')]
What I need is to have every second row of a table to have a different background colour. I have successfully created my method that can be called from the rml document and returns the hex colour. What I need is a way on rml side to set the background-colour attribute of the tr tag to the return value of my method. How can this be done ? I have been using the official documentation and looking specifically at the chapter 11 Conditional formatting but I do not see anything. Essentially what I want to do it the following:
<tr style="background-colour: [[_get_colour(index)]];" />
_get_colour will return a string that will contain the hex value of a colour
Edit: As it turns out the docIf RML tags that are used for conditional formatting are not implemented in openerp v7 according to this and I have to resort to a different solution.
Can't test this at the moment, but here's an idea that might work:
Make two <tr> for each iteration (1 for each style). In one of them, check if the index is even or removeParentNode('tr'), in the other, check if the index is odd or removeParentNode('tr'). This way only one or the other table row will display on each iteration, but not both.
Example (untested):
<tr style="style1">[[ (index%2 == 0 and display.content) or removeParentNode('tr')]]</tr>
<tr style="style2">[[ (index%2 != 0 and display.content) or removeParentNode('tr')]]</tr>
I found an example of that problem being solved in an rml in the system. I ended up resolving the issue with the following:
<tr>[[ setTag('tr','tr',{'style': 'Move_Line_Contect_Assign_State_background' if picking.move_lines.index(move_lines) % 2 else 'Move_Line_Contect_Assign_State'}) ]]
In the fifth column of my table which is populated from ajax, outside of the code is ==$0 which is not part of the html.
Screenshot from Chrome: http://i.imgur.com/vRioSrh.png
This breaks the whole table... I have no idea where this code is coming from.
Using datatables 1.10.12.
Oh, this appears to be a Chrome debugging value? I suppose it is not part of the actual document. There must be another issue in my table.
I am using Cucumber, watir-webdriver, page-object, and jruby. I am writing a method in a page class that enters a value into a text area. I am using a generated method in the page-object gem that, under the hood, invokes the Watir-Webdriver set method, that in turn invokes send_keys on the element.
Anyway, the problem for me is I am trying to add a VERY LARGE STRING (in order to test max size stuff for a validateable form object). It's 4000 characters and takes a noticeable amount of time to enter.
It would be great if there were a way to just paste the whole string into the text area at once. Is there any way to do this with the technologies I have on hand? These are..
JRuby, watir-webdriver, page-object (which really just delegates to watir-webdriver). I suppose under the hood it's selenium-webdriver that's doing the browser driver interaction in any case.
So far I haven't found a way around ultimately using send_keys which basically sends one key stroke at a time and that's why a huge character string is a pain.
You could directly set the value of the field using execute_script.
Given a page with a textarea:
<html>
<body>
<textarea></textarea>
</body>
</html>
Inputting the textarea with set took 6-9 seconds (with Firefox/Chrome):
input = 'a' * 4000
browser.textarea.set(input)
However, by using execute_script to directly set the value, it only took 0.2 seconds:
input = 'a' * 4000
field = browser.textarea
browser.execute_script('arguments[0].value = arguments[1];', field, input)
I'm trying to select an element given by:
/html/body[#id='someid']/form[#id='formid']/div[#id='someid2']/div[#id='']/div[#id='']/div[#id='']/table/tbody[#id='tableid']/tr[7]/td[2]
Now the html of that row I'm trying to select looks like this:
<tr>
<td class="someClass">some text</td>
<td class="someClass2">my required text for verifying</td>
</tr>
I need to check whether my required text for verifying exists in the page.
I used selenium.isTextPresent("my required text for verifying"); and it doesnt work
So now I tried with selenium.isElementPresent("//td[contains(text(),'my required text for verifying')]")
This works sometimes but occassionally gives random failures.
Tried with selenium.isElementPresent(//*[contains(text(),'my required text for verifying')]) too..
How do I verify this text on the page using selenium?
The problem is not with the page taking time to load. I took screenshots before the failure occurs and found that the page was fully loaded so that shouldnt be the problem.
Could someone please suggest any way to select this element or any way to validate this text on the screen?
Try locating it by CSS:
assertText(selenium.getText("css=.someClass2"), "my required text for verifying");
The above should give a better failure message than isElementPresent, but you can still use that with CSS locators:
assertTrue(selenium.isElementPresent("css=.someClass2"));
If there is an issue with the load times you could try waiting for the element to be present:
selenium.waitForCondition("var value = selenium.isElementPresent('css=.someClass2'); value == true", "60000");
Some other XPath locators that might work for you, if you prefer not to use CSS locators:
//td[contains(#class, 'someClass2')
xpath=id('tableid')/tr[7]/td[2]
xpath=id('tableid')/descendant::td[contains(#class, 'someClass2')][7]
I've never heard of selenium; but your initial XPath is unnecessarily fragile and verbose.
If an element has an id, it's unique; using such a long XPath just to select a particular element is unnecessary; just select the last element with the id. Further, I see that you're occasionally selecting xyz[#id=''] - if you're trying to select elements without id attributes, you can do `xyz[not(#id)] instead.
Assuming your initial XPath is basically correct, it would suffice to do something like this:
//tbody[#id='tableid']/tr[7]/td[2]
However, using a specific row and column number like that is asking for trouble if ever anyhow changes details of the html. Also, it's atypical to have id's on tbody elements, perhaps the table element has the id?
Finally, you may be running into space-normalization issues. In xml, multiple consecutive spaces are often considered equivalent to a single space, and you're not accounting for that. In particular, if the xhtml is pretty-printed and contains a line-break in the middle of your sought-after text, it won't work.
//td[contains(normalize-space(text()),'my required text for verifying')]
Finally, text() explicitly selects
child text nodes - so the above xpath won't select elements where the text isn't the immediate child of td (e.g. <td><b>my required text for verifying</b></td>) won't match. Perhaps you mean to look up the concatenated text vale of all descendents:
//td[contains(normalize-space(string(.)),'my required text for verifying')]
Finally, type conversion can be implicit in XPath, so string(.) can be replaced by . in the above, leading to the version:
//td[contains(normalize-space(.),'my required text for verifying')]
This may be slow on large documents since it needs to normalize the spaces and perform a string search for each td element. If you run into perf problems, try to be more specific about which td elements need to be inspected, or, if you don't care where the text occurs, try to reduce the number of "calls" to normalize-space by normalizing the entire doc in one go (e.g. via /*[contains(normalize-space(.),'my required text for verifying')]).