Trying to programmatically set value of a list item's URL column - google-apps-script

I'm trying to add a list item that contains a URL in its second column and I keep getting the following error:
Execution failed: The anchor tag supplied for the List Item was not
properly formed. (line 131, file "Code")
The lines in question (130 and 131) ares:
var values = [a,"< a href=\'DEBUG\'>details</a>",c,d,e,f,g,h];
var thislistitem = kbPage.addListItem(values);
I've tried passing the following for the second variable:
""
"<a href=\'DEBUG\'>details</a>"
DEBUG
http://www.something.com/
And I keep getting the same error. I expect that I should be passing a pair of values (a label and a url) somehow instead of a simple string, but I can find no reference anywhere to how to do that.

First of all there are three things:-
Coloumn in which want to enter the tag should be of URL type
Anchor tag should not have escape characters in between instead of
this "<a href=\'DEBUG\'>details</a>"
use "<a href='DEBUG'>details</a>"
Biggest mistake was space < a between < and a makes anchor tag invalid
Apply these things and it wont show any error

Related

Using Chrome.ahk library to fill out a field inside an iframe

Hello can anybody help me with trying to edit a field inside an ifram using CHROME.ahk
The following code works when I create an IE ojbect. This is the part I use to fill in the field.
workoder := test
frame := pwb.document.parentWindow.frames("uxtabiframe-1068-frame")
frame.document.GetElementsByName("ff_workordernum").item[0].Value := workorder
How do I do this using the chrome.ahk library.
and it doesn't work. I have tried several methods. Can anybody please help
I have trid this:
PageInstance.Evaluate("document.parentWindow.frames('uxtabiframe-1068-frame').document.GetElementsByName('ff_workordernum').item[0].Value = 'test' )
I get an error. I tried
iframeJs =
(
var iframe = document.getElementById('uxtabiframe-1068-frame');
var test2 = iframe.contentDocument..GetElementsByName('ff_workordernum').item[0].Value = 'test';
)
PageInstance.Evaluate(iframeJs)
I believe the problem with the first try you are trying to get the property "document" of the Iframe here:
frames('uxtabiframe-1068-frame').document
However Iframes have no such property, it's called "contentDocument"
I think this is silly and confusing that it is like this, just "document" makes more sense and should be the standard.
Also in the first try there is an opening double quote but there isn't a closing one.
In the second try there is a repeated "." here:
iframe.contentDocument..GetElementsByName
You only need one of them.
And also with the second try you've tried to assign a variable over multiple lines, everything must be on the same line and you can do that by using "`n" which is an escaped newline character.

Vaadin add custom validator and content mode

There are some fields to validate. Field's captions contains formatting like ", ", etc with the option captionAsHtml="true". When using someField.addValidator(..., errorString), the error message shows errorString and the field name in brackets(parenthesis) and it looks like that is not cool. Is there any way to show the field name in the validation error message with formatting.
Tried to use Notifications instead, but they used in beforeFormSaved and showed when the form is closed unlike using validators.
You did not share your code, but are you trying it this way?
TextField field = new TextField("<i>Caption</i>");
field.setCaptionAsHtml(true);
UserError componentError = new UserError("<b>Error</b>", ContentMode.HTML,
ErrorLevel.ERROR);
field.setComponentError(componentError);

jQuery: Unable to set values of cloned input element and cannot copy disabled property

I'm having issues setting up new values to cloned input fields.
clonedElement = element.clone(true); //This is a whole DIV which has inputs in it.
I then search for the inputs and modify as needed.
var newValue = "New Value";
$(clonedElement).find("#"+id).val(newValue);
every time I try to set a value (before appending the clonedElement) I get the following error.
Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable
however, this works using the same process.
$(clonedElement).find("#"+id).val("");
Also, changing values to attributes such as the name also work as expected
vew newName = "new_name";
$(clonedElement).find("#"+id).attr("name", newName);
I can set a blank value and empty the fields but I cannot pass any actual values, neither coming from another variable or even hard-coded values, only blank works.
Another thing I noticed is that the "disabled" property is not getting copied along with the cloned inputs. All other attributes and properties do get copied.
Any ideas how to get new values added to cloned elements before appending the element to the document?
Thanks in advance,
I figured what the problem was. there is an input type file among all of the inputs and since I was looping all inputs to set the value without filtering some input types, the loop broke whenever it reached a select.
To fix the issue i simple did something like this.
var newValue = "my new value";
$("#"+newId+":not(input[type=file])", clonedElement).val(newValue);
$("#"+newId+":input[type=file]", clonedElement).text(newValue);
that's a workaround that worked for me and can easily be improved.

HTML: How to show a list whose size is unknown in advance on a webpage?

I'm like to admit that my knowledge of HTML is very little.
Assume we have a button on our pagepage that calls a javascript function: check().
The check() function withdraws an array (contantly updated) of values, e.g. string, from a server. If each element of the array has a certain property, e.g. contain a letter "a", then it wants to print those strings on the webpage.
The upperbound of the array size retrieved from the server is known but we do not know in advance how many elements satisfies the condition checked by check().
Question how to print the elements found by check() on a HTML file (a webpage).
Let's assume javascrip is in the the HTLM file too.
With something like <div id="destination"></div> in the HTML as a placeholder, you can use JavaScript to loop through your array of items and insert each one into the HTML with:
document.getElementById('destination').innerHTML += '<p>' + myData + '</p>';

Selenium: How to get text from within an html tag which has another tag in it

<a class="spf-link current" href="/orders/returns?offset=0&limit=25">
<span class="pg-helpText">Page</span>
1
</a>
I need to read the value '1' in my test. When I do a get text using css-selector .spf-link.current, it gets me "Page 1". I only need '1'. How do I exclude the text from the span tag.
You will need Javascript childNodes to get the text from the nodes.
The childNodes property returns a collection of a node's child nodes,
as a NodeList object.
The nodes in the collection are sorted as they appear in the source
code and can be accessed by index numbers. The index starts at 0.
WebElement element = driver.findElement(By
.cssSelector(".spf-link.current"));
String node_text=(String)((JavascriptExecutor)driver)
.executeScript("return arguments[0].childNodes[2].nodeValue",element);
This should give you the value 1 as node_text when you run the JavascriptExecutor. Other way is to split the text Page 1 on the basis of space. But, i would prefer childNodes.
Let me know if you have any queries.
Try the following:
//span[#class="pg-helpText" and contains(text(), 'Page')]/following-sibling::span/span
It is not normal to customize untagged text between tags.
I recommend you to change the value to your desired result:
<a class="spf-link current" href="/orders/returns?offset=0&limit=25">1</a>
...and when you want to show it in other place, do it as var ThePage = "Page " + [the page number]
Other solution is to include it into another tag as a div or as another span with a different class or id.