With HTMX I know I can poll e.g. "/news" every 2 seconds like this:
<div hx-get="/news" hx-trigger="every 2s">div>
But it takes 2s before the is triggered the first time after page load. What I want to do is to trigger the call to "/news" as soon as the page is loaded and then poll every 2s.
I've tried things such as:
<div hx-get="/news" hx-trigger="on load or every 2s">div>
and
<div hx-get="/news" hx-trigger="on htmx:afterOnLoad or every 2s">div>
But none of this works. How can I do this with HTMX?
(I know this is generally a bad practice with HTMX since you could just include the data from the server in the response, but I'd like to know out of curiosity :))
You can add multiple triggers separated by comma. So this should probably work:
<div hx-get="/news" hx-trigger="load, every 2s">div>
Related
I am trying to Input text into text box using the Robot framework selenium library and the same gets vanished just after typing. The script passes but the value is not actually passed
input text
//*[text()="Daily Order Limit"]/../../../input 150
I have tried to put more, Click the element and then Input text, Wait until element visible/enabled.
If this the HTML Code of text box element
<input aria-invalid="false" name="limit" placeholder="Daily Order Limit"
type="number" class="MuiInputBase-input MuiOutlinedInput-input" value="">
You can use the below mentioned xpath
Input Text //input[#class='MuiInputBase-input MuiOutlinedInput-input'] 150
OR
Input Text //input[#placeholder='Daily Order Limit'] 150
You see the text getting filled in, but it disappears after typing? Sounds like the page is not fully loaded yet, as in the input is loaded but some ajax/javascript/... refreshes the page. Normaly you wouldn't noticr but Selenium is SO fast that it happens.
Try this:
Sleep 5s
//*[text()="Daily Order Limit"]/../../../input 150
Note that Sleep or hard waits in general are a bad solution. If this works, the next step is figuring out how to detect when the page is REALLY finished loading.
I have a few pages on which I am running nightwatchjs to execute an end to end test.
<div role="tab" aria-selected="true" title="My TV"><span>MyReal TV</span></div>
I have a few tabs that I try to verify using code similar to below:
.verify.elementPresent('div[role="tab"][title="Portfolio"]', 1000)
The above works fine for the Portfolio tab. However, I have two tabs that fail and is returning not found. My Tv and Daily Report . Below fails for My Tv:
.verify.elementPresent('div[role="tab"][title="My Tv"]', 1000)
The Daily Report fails as well. I am wondering if it has something to do with the space in my title? Is there anything else I am doing wrong?
It turns out the url was wrong in my case. It was frustrating, spent hours to learn this.
Something like below was returned for the url
http://stackoverflow.com//questions
Instead of
http://stackoverflow.com/questions
I got a website with the following code:
<div id="past">
<div data-rollid="99999" class="ball kugel-2">2</div>
<div data-rollid="99998" class="ball kugel-2">2</div>
<div data-rollid="99997" class="ball kugel-2">2</div>
I want to get this number "2". I know that I can pickup the "past" by
past := wb.document.getElementById("past")
but how to get the value from the first child node?
You don't give a lot to work with, but you might try, for the first "undertag":
wb.Document.getElementByID("past").childnodes.item[0].innerText
For the second "undertag":
wb.Document.getElementByID("past").childnodes.item[1].innerText
etc.
Else, look at something like this:
wb.document.body.querySelector("data-rollid='99998']").innerText;
or
wb.document.getElementByID("past").querySelector("data-rollid='99998']").innerText;
or even
wb.document.getElementByID("past").childnodes.querySelector("data-rollid='99998']").innerText;
Which might work (you might have to play around with the syntax) . . .
Hth,
This can get you all the elements of a certain class:
elements:=ie.document.getElementsByClassName("ball kugel-2")
Or you can do this:
past:= wb.document.getElementById("past")
children:=past.children
while(a_index <= children.length, i:=a_index-1)
msgbox, % children[i].innertext
I have issues getting the text from an element in protractor. For other elements of the page it works as expected, just not for this one :/
<p class="error theme-info-i ng-binding ng-scope" ng-if="firstFormError && form.$invalid" ng-click="goToErrorField(firstFormError)">
<span class="emphasize ng-binding">User ID</span> (The user ID is required.)
</p>
I can locate both elements without problems using by.className, and getInnerHtml/getOuterHtml works as expected. However getText returns an empty string for both.
Found the reason ... its a two-step registration where the first step has the same notification area and just gets hidden. For reasons beyond my comprehension the devs update both notification areas (not just the one on the current page), so inner/outerHtml just seemingly returned the "correct content" and because the first area was hidden, getText returned empty as by spec.
I think I'm gonna file some internal bug report now wtf we are doing with those notifications ;)
You can try
var firstName = element(by.model('firstName'))
expect(firstName.getAttribute('value'))
This gives you the value of the input box.
Had the same problem.
expect(element(By.css('span.emphasize.ng-binding')).getAttribute('textContent'))...
Seems to work just fine for me (this of course if you have only one span with those classes or is the first one. else you need to be more specific. But anyway if you still need to solve the problem try with .getAttribute('textContent') )
I have a div with a unique ID. Under that div are a bunch of span elements that have className=foo. There are several span elements with className=foo but they are unique to each div (if that's clear). So my Selenium code first gets the unique div as a web element then tries to take that element and get by class name the span like so
element = sDriver.findElement(By.id("c_"+cID));
String sTest = element.findElement(By.className("actions")).getText();
On the second line it throws an exception every time
org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
Command duration or timeout: 22 milliseconds
Do I misunderstand how to get that span from under a unique div?
Nope you'right accessing the span but the problem is that the Dom has changed since StaleReferenceException is about (see StaleReferenceException )
This may be caused because the page isn't loaded completely when the code starts or changes when the code is executed. You can either try to wait a little longer for the element or catch the StaleReferenceException and try again finding the div and the span.
My solution is not fancy but it works like a Swiss watch (in my situation of course). So my code is calling the parent element in a loop looking for different child elements in it. Nothing got changed at all - just simple querying and the exception began to occur. So! I've added the Thread.Sleep(2000) command before every search of parent element and it solver the problem. Not elegant but works every time with minimum code to debug afterwards.