Repeatable attribute tags in markojs - marko

I want a custom tag for tabs that will give me the possibility to write following code
app-tabset#my-tab
#tab title="first"
p -- content of first tab
#tab title="second"
p -- content of second tab
but I can't get it to consume repeated attribute, hence in app-tabset.marko
onMount() {
console.log('incoming tabs', this.input.tab)
// expected an array but only object of second tab
// "{title="second", renderBody: function}"
}
Reading the docs in repeated attribute tags i add a marko-tag.json
{
"<tab>": {
"is-repeated": true
}
}
This compiles fine but when loading the page i get
Render async fragment error (lasso-slot:head).
Exception: Error: Unable to load tag ([C:\projects\marko\src\components → C:\projects\marko\src\components\app-tabset\marko-tag.json]):
Error: Error while applying option of "<tab>".
Cause: Error: Unsupported properties of [is-repeated]

In case you haven't found a solution yet, try this in your marko-tag.json file
{
"#tabs <tab>[]": {
"#title": "string"
}
}

Related

Setting the Group Bypass property of a Node

I can't seem to find an answer from the documentation http://origen-sdk.org/origen/guides/program/flowapi/
From SmartTest 7.1.3 and later of Advantest, we have the option to set “Group Bypass” property of the Group node testflow component.
{
run_and_branch(TestA)
then
{
}
else
{
if #Alarm then
{
binout;
}
else
{
}
}
run_and_branch(TestB)
then
{
}
else
{
if #Alarm then
{
binout;
}
else
{
}
}
}, groupbypass, open,"DataCollectionTests", ""
I tried using if_flag:, continue: and if_enable properties in my group definition but I’m getting an
if #GROUPBYPASS == 1 then
{
.
.
.
}, open,"DataCollectionTests", ""
in the flow instead.
What is the correct way of hooking up into this property?
This property is not currently supported, if you want it added please open a ticket describing it here: https://github.com/Origen-SDK/origen_testers/issues
In the meantime, you could generate it by using the render method which allows you to explicitly define code to be injected into the flow.
For example:
render '{'
# Your existing code to be wrapped in the group here, e.g.
test :testA
render '}, groupbypass, open,"DataCollectionTests", ""'
You could create your own helper method for that within your interface:
def group_bypass(name)
render '{'
yield
render "}, groupbypass, open,\"#{name}\", \"\""
end
Then in your flow:
group_bypass "DataCollectionTests" do
# Your existing code to be wrapped in the group here, e.g.
test :testA
end

nodejs+selenium-driver NoSuchElementError & StaleElementReferenceError

I am doing a test based mocha. node v8.2.1, selenium-webdriver: ^3.5.0.
test.it('demoClass', () => {
driver.classes[0].findElement(By.css('.class-avatar')).click();
driver.wait(until.elementIsVisible(driver.findElement(By.css('.anticon.anticon-plus'))));
//driver.sleep(2000);
driver.findElement(By.css('.anticon.anticon-plus')).click();
})
I am getting two different types of errors, either its NoSuchElementError: no such element: Unable to locate element: or StaleElementReferenceError: stale element reference: element is not attached to the page document
But whichever error, its refer to line:
driver.findElement(By.css('.anticon.anticon-plus')).click();
When I use driver.sleep(2000), its getting resolved. In my opinion, It's the question of animation. I can get the element(.anticon.ancicon-plus) only at the time, the page's animation is completed.
what I am confused is that I use driver.wait(until.elementIsVisible()) without an error, It's obvious that I got the element. but at the next line, I can't use it. Or NoSuchElementError, or StaleElementReferenceError.
I find some answer like http://www.seleniumhq.org/exceptions/stale_element_reference.jsp,https://stackoverflow.com/questions/18225997/stale-element-reference-element-is-not-attached-to-the-page-document. But It can't help me.
when use driver.findElement, something terrible will be triggered. use javascript instead it.
driver.executeScript(function() {
while(true) {
if(!document.querySelector('.anticon.anticon-plus')){}
else {
document.querySelector('.anticon.anticon-plus').click();
break;
}
}
return true; // not neccessary
})

Is there a way in Geb to automatically assign the right Module to all Elements in a Form

We use Geb to run our Frontend Tests and we have some quite complex pages in our application.
Some of the pages have forms with a lot of different buttons, checkboxes and some multiselects.
I love the feature of geb/groovy that i just have to define the form in the Page Object and then can access all its elements in it.
static content = {
form { $("#form")}
}
But for them to be clickable and to query if they are readonly and more they need to be at least of type FormElement which does not happen with the above method. So I have to mention all these FormElements separately:
static content = {
form { $("#form")}
button1 { $("#button1").module(FormElement)}
button2 { $("#button2").module(FormElement)}
checkbox{ $("#checkbox").module(Checkbox)}
...
}
All those buttons, checkboxes... are already in the form variable, but cannot be clicked or checked if they are selected and so on. It's also not possible to apply the the module afterwards like this:
def "test something"() {
when:
form.button1.module(FormElement).click() //error
then:
...
}
Is there no way to automatically assign each input, checkbox, radiobutton, button,... the correct Module based on their type without the need of doing it by hand?
If someone could also point me in the right direction to understand how this "form { $("#form")}" works, that i can access all sub elements by its name by just suppying the form, that would be nice!
For your example of creating a module based on a form control you need to obtain a navigator for the control and not it's value. It's done by calling a method named the same as the control you're trying to access (it's explained in this section of The Book of Geb):
form.button1().module(FormElement).click()
If you want to automatically create modules based on the element type then you could create a Module for the form and override method missing:
class FormModule extends Module {
Object methodMissing(String name, Object args) {
def result = super.methodMissing(name, args)
if (result instanceof Navigator && result.tag() == "input") {
switch (result.#type) {
case "checkbox":
result = result.module(Checkbox)
break
default:
result = result.module(FormElement)
}
}
result
}
}
then you would use it like:
static content = {
form { $("#form").module(FormModule) }
}
form.button1().click()

Watch for element visibility change in angulardart

I have the same exact question that has already been posted for angularjs (Angular - Watch for ngShow/ngHide Changes in Ancestors that Affect Child DOM Element's Visibility) except in my case we are using angulardart. I cannot seem to watch a function in angulardart. When I try to, I get an error from the expression parser stating that "{" is unexpected. Is there a better way to do this in angulardart? If not, how can I watch a function similar to angularjs?
I've tried the following code with no success:
scope.watch("() { return _element.hidden; }", (value, _) {
print(value);
});
Parser Error: Unexpected token ) at column 2 in [() { return _element.hidden; }]
scope.watch("(scope) { return _element.hidden; }", (value, _) {
print(value);
});
Parser Error: '{' is an unexpected token at column 9 in [(scope) { return _element.hidden; }]
We are using angular.dart 1.1.2
You could use MutationObserver, it notifies about DOM changes. See for example In Dart why the code below (about MutationObserver) dose not work? (there should be more examples on SO)

Elasticsearch-groovy index template

Is there any way to define an index template with the API of elasticsearch-groovy or elasticsearch-java? I want to apply "settings" (custom analyzers) and "mappings" (apply analyzer on fields) on it. The documentation only refers to index templatex but does not show a vaild example, how to apply them in a groovy closure. The example shown in the docs, adds the "settings" in the data (source) field.
edit: #Val Thank you for your reply, but if I use the source field as follows:
def templateR = client.admin.indices.putTemplate {
name "template_name"
source {
template "template_*"
}
}.actionGet()
... this results in a compiler-error: MissingMethodException No signature of method: ...source(). The following code:
def templateR = client.admin.indices.putTemplate {
name "lemato_template"
template "lemato_*"
settings {
number_of_shards= 1
}
}.actionGet()
gives me the compiler error No such property: number_of_shards. I'm not sure if I use the closure delegation correctly. Is something like .asMap() missing?
elasticsearch-groovy definitely provides support for creating/deleting index templates. The source closure may contain anything you can define for index templates. Something like this should work.
PutIndexTemplateResponse response = client.admin.indices.putTemplate {
name "my_template"
source {
template "index_*"
settings {
index {
number_of_shards = 5
number_of_replicas = 1
}
}
mappings {
// your mapping definitions
}
aliases {
// your aliases
}
}
}.actionGet()

Resources