Automate with watir on-screen keypad login - watir

I'm wondering how to automate with watir the clicks on a on-screen keypad. I'm trying to automate the login on this web, but I don't know how to recognize the numbers and click on them:
https://bancaelectronica.evobanco.com/

If you look at the HTML of the keyboard, each key is simply a link:
<div class="virtual_keyboard active">
<ul>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">3</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">7</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">1</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">0</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">4</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">5</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">6</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">2</a></li>
<li><a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">8</a></li>
<li class="correction">
<a id="btCorrect" href="javascript:void(0);" data-target=".activeInput" class="keypad-btn delete-key">Corregir</a>
</li>
<li>
<a data-target=".activeInput" class="keypad-btn value-key" href="javascript:void(0);">9</a>
</li>
</ul>
Cerrar
</div>
You simply need to:
Activate the keyboard by clicking on the password field
Clicking the key links by text (since they are randomly sorted)
An example of typing a password of "123":
browser = Watir::Browser.new :chrome
browser.goto('https://bancaelectronica.evobanco.com/')
# Activate the keyboard
browser.text_field(id: 'cFDMTuKLOsuyeXQ').click
# Wait until the keyboard appears
virtual_keyboard = browser.div(class: 'virtual_keyboard')
virtual_keyboard.wait_until_present
# Enter the password by clicking the number links
virtual_keyboard.link(text: '1').click
virtual_keyboard.link(text: '2').click
virtual_keyboard.link(text: '3').click
The same approach can be taken for other on-screen keyboards. However, the exact elements to interact with will depend on the page's implementation of the keyboard.

Related

How to configure Wayfinder (MODx) for Bootstrap 5 Dropdown-Menu

how do I have to configure the "Wayfinder" in MODx to get a Bootstrap 5 output. specifically for the "Dropdown Submenue".
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav me-auto mb-2 mb-md-0">
<li class="nav-item active">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false" href="#">Project</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">How-To</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</div>
I think it has to be the innerTpl and the innerRowTpl. The normal (level 1 menu) works. Just not the submenu.
How do I have to configure that?
The Wayfinder call:
[[Wayfinder? &startId=`0` &level=`2` &outerClass=`navbar-nav me-auto mb-2 mb-md-0` &rowTpl=`tpl_navigation-menu` &rowClass=`nav-item` &innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`]]
&rowTpl:
<li[[+wf.id]][[+wf.classes]]><a href="[[+wf.link]]" class="nav-link" title="[[+wf.title]]" [[+wf.attributes]]>[[+wf.linktext]]</a>[[+wf.wrapper]]</li>
&innerTpl and innerRowTpl is still blank.
Did someone have an Idea?
Wayfinder often confusing here unfortunately, please take a look at snippet documentation diagram, it will help you to understand which chunks are used to form menu child elements.
OK,
here is the final solution. (For those who struggels with the Wayfinder-Stuff as me)
[[Wayfinder?
&startId=`0`
&level=`2`
&outerClass=`navbar-nav me-auto mb-2 mb-md-0`
&innerClass=`dropdown-menu`
&rowTpl=`tpl_row`
&parentRowTpl=`tpl_parentrow`
&innerRowTpl=`tpl_innerrow`
]]
Chunk for tpl_row:
<li class="nav-item [[+wf.classnames]]">
<a class="nav-link" href="[[+wf.link]]">[[+wf.linktext]]</a>
[[+wf.wrapper]]
</li>
Chunk for tpl_parentrow:
<li class="nav-item dropdown [[+wf.classnames]]">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false" href="[[+wf.link]]">[[+wf.linktext]]</a>
[[+wf.wrapper]]
</li>
Chunk for tpl_innerrow:
<li class="[[+wf.classnames]]">
<a class="dropdown-item" href="[[+wf.link]]">[[+wf.linktext]]</a>
[[+wf.wrapper]]
</li>

Selenium - How to determine the value on click (findElement)?

If I have a header on HTML like these:
<li class="nav-item px-1 pt-1">
<a class="nav-link" href="http://localhost/ciblog/">Home</a>
</li>
<li class="nav-item px-1 pt-1">
<a class="nav-link" href="http://localhost/ciblog/Book">Book</a>
</li>
<li class="nav-item px-1 pt-1">
<a class="nav-link" href="http://localhost/ciblog/TestCreate">Create</a>
</li>
and I want to click on "Book", how do it?
Here's what I tried:
await driver.findElement(By.css('a.nav-link')).click();
and I'm understand that won't work because all of them have nav-link class, how do I call the specific value of book? on Selenium IDE you can just input value = Book
You can locate it with XPath:
await driver.findElement(By.xpath("//a[contains(text(),'Book')]")).click();
Or with css selector
await driver.findElement(By.css("a[href*='Book']")).click();
I would say to go ahead with linkText :
await driver.findElement(By.linkText("Book")).click();

How to configure Wayfinder (ModX Revo) to geht this output

I can't figure out how I have to configure Wayfinder (or pdoMenue) to get this output:
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">
<p>Home</p>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="articles.html">
<p>Articles</p>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">
<p>About</p>
</a>
</li>
</ul>
Can anybody help me out?
Edit: I have a dropdown too:
<li class="nav-item dropdown">
<a href="index.html#" class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown">
<i class="now-ui-icons files_paper" aria-hidden="true"></i>
<p>Sections</p>
</a>
<div class="dropdown-menu dropdown-menu-right" aria- labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="sections.html#headers">
<i class="now-ui-icons shopping_box"></i>
Headers
</a>
<a class="dropdown-item" href="sections.html#features">
<i class="now-ui-icons ui-2_settings-90"></i>
Features
</a>
</div>
</li>
It is the free Template Now UI-Kit, and based on bootstrap 4.
[[pdoMenu?
&parents=`0`
&level=`1`
&tplOuter=`#INLINE <ul[[+classes]]>[[+wrapper]]</ul>`
&tpl=`#INLINE <li[[+classes]]><a class="nav-link" href="[[+link]]" [[+attributes]]><p>[[+menutitle]]</p></a>[[+wrapper]]</li>`
&outerClass=`navbar-nav ml-auto`
&rowClass=`nav-link`
]]
Something like this in pdoMenu. Untested, you may have to play around with how the classes get assigned. If you need first and last classes, or a you-are-here class, those are available too and well-documented. https://docs.modx.pro/en/components/pdotools/snippets/pdomenu

Best way to make article content available offline using node.js

What is the best way to make any kind of article/blog content to make available offline or make it readable more like pocket using node.js ?
How do I perform downloading whole page including it's resources for offline use.
the link https://nodejs.org/api/ has all the child pages
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Node.js v5.3.0 Manual & Documentation</title>
<link rel="stylesheet" href="https://fonts.googleapis.com /css?family=Lato:400,700,400italic">
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
<link rel="canonical" href="https://nodejs.org/api/index.html">
</head>
<body class="alt apidoc" id="api-section-index">
<div id="content" class="clearfix">
<div id="column2" class="interior">
<div id="intro" class="interior">
<a href="/" title="Go back to the home page">
Node.js (1)
</a>
</div>
<ul>
<li><a class="nav-documentation" href="documentation.html">About these Docs</a></li>
<li><a class="nav-synopsis" href="synopsis.html">Synopsis</a> </li>
<li><a class="nav-assert" href="assert.html">Assertion Testing</a></li>
<li><a class="nav-buffer" href="buffer.html">Buffer</a></li>
<li><a class="nav-addons" href="addons.html">C/C++ Addons</a></li>
<li><a class="nav-child_process" href="child_process.html">Child Processes</a></li>
<li><a class="nav-cluster" href="cluster.html">Cluster</a></li>
<li><a class="nav-console" href="console.html">Console</a></li>
<li><a class="nav-crypto" href="crypto.html">Crypto</a></li>
<li><a class="nav-debugger" href="debugger.html">Debugger</a> </li>
<li><a class="nav-dns" href="dns.html">DNS</a></li>
<li><a class="nav-domain" href="domain.html">Domain</a></li>
<li><a class="nav-errors" href="errors.html">Errors</a></li>
<li><a class="nav-events" href="events.html">Events</a></li>
<li><a class="nav-fs" href="fs.html">File System</a></li>
<li><a class="nav-globals" href="globals.html">Globals</a></li>
<li><a class="nav-http" href="http.html">HTTP</a></li>
<li><a class="nav-https" href="https.html">HTTPS</a></li>
<li><a class="nav-modules" href="modules.html">Modules</a></li>
<li><a class="nav-net" href="net.html">Net</a></li>
<li><a class="nav-os" href="os.html">OS</a></li>
<li><a class="nav-path" href="path.html">Path</a></li>
<li><a class="nav-process" href="process.html">Process</a></li>
<li><a class="nav-punycode" href="punycode.html">Punycode</a></li>
<li><a class="nav-querystring" href="querystring.html">Query Strings</a></li>
<li><a class="nav-readline" href="readline.html">Readline</a></li>
<li><a class="nav-repl" href="repl.html">REPL</a></li>
<li><a class="nav-stream" href="stream.html">Stream</a></li>
<li><a class="nav-string_decoder" href="string_decoder.html">String Decoder</a></li>
<li><a class="nav-timers" href="timers.html">Timers</a></li>
<li><a class="nav-tls" href="tls.html">TLS/SSL</a></li>
<li><a class="nav-tty" href="tty.html">TTY</a></li>
<li><a class="nav-dgram" href="dgram.html">UDP/Datagram</a></li>
<li><a class="nav-url" href="url.html">URL</a></li>
<li><a class="nav-util" href="util.html">Utilities</a></li>
<li><a class="nav-v8" href="v8.html">V8</a></li>
<li><a class="nav-vm" href="vm.html">VM</a></li>
<li><a class="nav-zlib" href="zlib.html">ZLIB</a></li>
now call these pages by node.js
var Client = require('node-rest-client').Client;
client = new Client();
var fs = require('fs')
client.get("https://nodejs.org/api/buffer.html",
function(data, response){
console.log(data.toString());
});
now use fs to save the file

In Orchard 1.3.10 and Advanced Menu 1.3 using classes "Current" and "Selected"

I'm using Orchard 1.3.10 and Advanced Menu 1.3 i have an issue with the classes assigned (current and selected).
I have a menu item "Teste1" and another menu item "Teste1 Sample".
When i selected the "Teste1 Sample", is inserted the class "current" to this, and insert "current selected" to "Teste1" item.
They are at the same level.
<ul id="menu-20" class="menu menu-main sf-menu sf-js-enabled sf-shadow">
<li><a class="title" href="/">Home</a></li>
<li class="current selected"><a class="title" href="/Orchard1.3.10/teste1">teste1</a></li>
<li><a class="title" href="/Orchard1.3.10/teste2">teste2</a></li>
<li><a class="title" href="/Orchard1.3.10/teste3">teste3</a></li>
<li class="current"><a class="title" href="/Orchard1.3.10/teste1-sample">teste1 sample</a></li>
<li><a class="title" href="/Orchard1.3.10/teste12">Teste12</a></li>
</ul>
Or if i select the "Teste12" is the same issue.
I don't know why this is happening.
Is this a Bug?

Resources