Embeddable collapsible sections in asciidoctor - asciidoctor

If there is a possibility to embed collapsible sections in another collapsible section in asciidoctor?
I am trying to achieve something like (here Address is embedded in Customer):
I tried typing something like that (but unfortunately that doesn't work):
.first
[%collapsible]
====
First val
.second
[%collapsible]
====
Second val
====
====

Yes. You can nest blocks provided that the delimiter lines differ. When you use the same number of equals signs, Asciidoctor cannot tell that you are starting a new block instead of closing the first block.
Try this instead:
.first
[%collapsible]
====
First val
.second
[%collapsible]
=====
Second val
=====
====

Related

NodeJS simple horizontal line on console.log

I'm making a simple Node JS app.
It logs a lots of informations on console. I would like to know if it's possible to add a horizontal lines in Node JS command line without using any extra packages or dependencies.
If command prompt supports HTML elements, then I could use something like console.log("<hr>"); for adding a horizontal line but it does not support HTML.
Is there any way ?
To create the string for the horizontal line:
const line = '-'.repeat(process.stdout.columns)
.repeat() method repeats the string.
process.stdout.columns returns the number of columns.
To use it:
console.log(line)
The console does not support rendering HTML elements.
That does not prevent you from making a custom line however!
const lineBreak = '----------------------'
console.log(lineBreak)
Of course, customize the linebreak however you'd like:
______ //Underscores!
----- //Hyphens!
====== //Equals!
For grouping related data, refer to the docs here: console reference
Example:
function name(obj) {
console.group('name');
console.log('first: ', obj.first);
console.log('middle: ', obj.middle);
console.log('last: ', obj.last);
console.groupEnd();
}
name({"first":"Wile","middle":"E","last":"Coyote"});
Will output grouped data to the console, visually giving it a line break & arrow to collapse the group. I think this would work well for your use case.
Working off on the same vane as #sergey above:
If your output has a header of a determinable length you can use the .length method.
const header="This is my header";
console.log(header);
console.log('-'.repeat(header.length);

If certain thing is included in input use anything after it

Hello I am currently working on a script that goes onto a website and automatically adds an Item to cart and purchases it for you I have a script that works except the only problem is that It is only able to checkout a single Item Item. Here is an example fo the script:
Item_code = input('Item code: ')
Size = input('Size: ')
def BOT():
driver = webdriver.Chrome(executable path=
URL = .....
driver.get(URL)
while True:
try:
driver.find_element_by_css_selector(Item_code).click()
break
except NoSuchElementException:
driver.refresh()
select = Select(driver.find_element_by_id('s'))
select.select_by_visible_text(Size)
The script finds the item with the item code that I use and then selects the size from the users choice
I want to be able to write the code and the size but If I want to bot to cart two Items in different sizes I want it to type in a , and insert the next Item code and Size For example:
12345, 6789
Large, Medium
I want to somehow write that if a comma is included to read and use the code after it after it uses the first one and repeat that for every comma so If I wanted to get 3 or even 4 all I would have to do is this:
1234, 5678, 7890, etc...
Large, medium, Small, etc...
If anyone could Help me out I would really appreciate it I was thinking of something like
for , in BOT():
(something like this but Im not sure )
I know how to tell the script that if Item_code == (',') then do this but that would not work because it needs to be just the comma and I do not know how to tell it to repeat the BOT() a second time and use the second code and size
If someone could help me out I would really appreciate it thanks.
(I want to be able to share this bot since I have already made a GUI for it and all that)
(not sure if the executable path will work when sharing)
I have fixed this problem I created several custom functions and called them on special if statements
ex.
if Item.count(',') == (1):
Cart1()
Checkout()
etc.....

Writing an impex to change the HMC Login attribute to enabled for all employees

I have the current problem that many of my employees in Hybris have the HMC login attribute set to inherit from group, which means that they can't log in to the HMC. This was due to that I used an impex script that set new users to this a while ago. I try now to write an impex script that updates all employees to have HMC access instead. I found the <ignore> tag to be interesting on the Wiki which states that "There is a special value that makes the ImpEx skip the entry and leave the item value at the one it currently is." (https://wiki.hybris.com/display/release4/ImpEx+Syntax). So when I am trying to use the following script:
UPDATE Employee;UID[unique=true];password;description;name;groups(uid);sessionLanguage(isocode);sessionCurrency(isocode);hmcLoginDisabled[default=false]
;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>
I think it should ignore all current values and set hmcLoginDisabled to false. But HAC gives me the following output:
UPDATE Employee;UID[unique=true];password;description;name;groups(uid);sessionLanguage(isocode);sessionCurrency(isocode);hmcLoginDisabled[default=false]
,,no existing item found for update;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>;<ignore>
27.03.2014 15:26:38: ERROR: line 3 at main script: Can not resolve any more lines ... Aborting further passes (at pass 2). Finally could not import 1 lines!
27.03.2014 15:26:38: ERROR: line 3 at main script: Can not resolve any more lines ... Aborting further passes (at pass 2). Finally could not import 1 lines!
Anyone that has any idea on how to write an impex script to solve this?
Just considered Nevins post and came up with this final solution that actually worked:
UPDATE Employee[batchmode=true];itemtype(code)[unique=true];hmcLoginDisabled[default=false]
;Employee
You can just leave the fields blank if you don't want to update the value.

Groovy string replace add new line

Got a groovy script that is pulling some text from a soap connection and I am trying to add a bullet point before any bullet points. Here is the code I have but it does not work and it may never work, but thought I would ask.
td (it.#detail.toString().replaceAll('>', '>').replaceAll("•", "\n •"))
That should work.
ie, try:
println it.#detail.toString().replaceAll('>', '>').replaceAll("•", "\n •")
To see it working in the console output.
I guess you're viewing this in HTML with a browser?
Newlines don't appear in HTML normally, so you'd need to wrap the text in a <pre> tag.
Assuming this is with StreamingMarkupBuilder or similar, try:
td {
pre( it.#detail.toString().replaceAll('>', '>').replaceAll("•", "\n •") )
}

How do I get the HTML in an element using Capybara?

I’m writing a cucumber test where I want to get the HTML in an element.
For example:
within 'table' do
# this works
find('//tr[2]//td[7]').text.should == "these are the comments"
# I want something like this (there is no "html" method)
find('//tr[2]//td[7]').html.should == "these are the <b>comments</b>"
end
Anyone know how to do this?
You can call HTML DOM innerHTML Property:
find('//tr[2]//td[7]')['innerHTML']
Should work for any browser or driver.
You can check all available properties on w3schools
This post is old, but I think I found a way if you still need this.
To access the Nokogiri node from the Capybara element (using Capybara 1.0.0beta1, Nokogiri 1.4.4) try this:
elem = find('//tr[2]//td[10]')
node = elem.native
#This will give you a Nokogiri XML element
node.children[1].attributes["href"].value.should == "these are the <b>comments</b>"
The last part may vary for you, but you should be able to find the HTML somewhere in that node variable
In my environment, find returns a Capybara::Element - that responds to the :native method as Eric Hu mentioned above, which returns a Selenium::WebDriver::Element (for me). Then :text gets the contents, so it could be as simple as:
results = find(:xpath, "//td[#id='#{cell_id}']")
contents = results.native.text
if you're looking for the contents of a table cell. There's no content, inner_html, inner_text, or node methods on a Capybara::Element. Assuming people aren't just making things up, perhaps you get something different back from find depending on what else you have loaded with Capybara.
Looks like you can do (node).native.inner_html to get the HTML content, for example with HTML like this:
<div><strong>Some</strong> HTML</div>
You could do the following:
find('div').native.inner_html
=> '<strong>Some</strong> HTML'
I ran into the same issue as Cyril Duchon-Doris, and per https://github.com/teampoltergeist/poltergeist/issues/629 the way to access the HTML of an Capybara::Poltergeist::Node is via the outerHTML property, e.g.:
find('//tr[2]//td[7]')['outerHTML']
Most of the other answers work only in Racktest (as they use Racktest-specific features).
If your driver supports javascript evaluation (like Selenium) you can use innerHTML :
html = page.evaluate_script("document.getElementById('my_id').innerHTML")
If you're using the Poltergeist driver, these methods will allow you to inspect what matches:
http://www.rubydoc.info/gems/poltergeist/1.5.1/Capybara/Poltergeist/Node
For example:
page.find('[name="form-field"]').native.value == 'something'
try calling find('//tr[2]//td[10]').node on it to get at the actual nokogiri object
Well, Capybara uses Nokogiri to parse, so this page might be appropriate:
http://nokogiri.org/Nokogiri/XML/Node.html
I believe content is the method you are looking for.
You could also switch to capybara-ui and do the following:
# define your widget, in this case in your role
class User < Capybara::UI::Role
widget :seventh_cell, [:xpath, '//tr[2]//td[7]']
end
# then in your tests
role = User.new
expect(role.widget(:seventh_cell).html).to eq(<h1>My html</h1>)

Resources