opening tap target in materialize css for 2 seconds - materialize

I need to open Tap target in materialize css for 2 seconds & close it. All I can see is ('.tap-target').tapTarget('open'); & $('.tap-target').tapTarget('close');
Is there a way to open it for a specific time(say 2 seconds) & close it.
Also , is there a way to set its size on the screen ?
TIA
Jagan

You can use setTimeout to "schedule" the execution of a piece of code in the future, e.g. in 2 seconds from now:
$('.tap-target').tapTarget('open');
setTimeout(function(){ $('.tap-target').tapTarget('close'); }, 2000);
It will wait the given number of milliseconds (here 2000) and then execute the given function. Give this a try, it should be fairly straightforward.
I don't understand your 2nd question about the size though.

Related

Selenium: Checking if several elements are not visible takes too much time

In one of my testcases, im checking if some elements are NOT visible.
Its very simple:
Login
Check if 5 buttons inside the left menu bar are not visible (As the user has no rights)
End test
This shouldnt take more than 10 seconds to test.
But as im using implicit wait, it does always wait 5 seconds for each button, which causes the test to take way too much time to finish. Currently it takes more than 30 seconds just to test if 5 buttons are not visible.
Im using this method:
var elements = _webDriver.FindElements(By.XPath(selector));
if (elements.Count > 0)
{
throw new Exception(selector + " still displayed");
}
Are there any other ways how to make this work?
Use a explicit wait to check for the first element and then just check the other elements directly (with implicitly_wait = 0).
something like:
try:
element = WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.XPATH, selector))
)
except TimeoutException:
# no element found
if element:
# check the presence of the other elements with find_element
documentation:
https://selenium-python.readthedocs.io/waits.html

How to run a test against a certain predefined timestamp in playwright

I'm trying to run a playwright test that keeps failing the screenshot match because of timestamps (ex. 3 hours ago, 1 day ago, 5 days ago) that are posted on the page next to some content, not matching the current timestamps that have changed because the test is being run after the initial baseline screenshot is taken.
What is a way that I can store the current date and time at the time of capturing baseline screenshots and telling playwright this is always the timestamp I want to compare against in all tests?
As I see it, as long as you don't ignore the date comparison in your screenshots, they will keep throwing errors. Take into account your snapshot is just a moment in time, we may say. so if your baseline snapshot (the one you compare your current status against) contains the text "5 days ago", that's unchangeable unless you update the snapshot, but the whole comparing snapshots is all about comparing current state vs previous state to check there are no unwanted regressions, so updating the snapshot for this test every time would not make much sense.
In my opinion, you should ignore the given text. A good way to do it is using the option "mask" included in version 1.20. So imagine you want to ignore the number of stars the playwright repo has in its homepage. You could do this:
test('homepage', async({ page }) => {
await page.goto('https://playwright.dev/');
const stars = page.locator('.gh-count');
expect(await page.screenshot({ mask: [stars] })).toMatchSnapshot();
});
This would take a snapshot of playwright's homepage, masking the element with the stars count, sticking the element into a pink-coloured box. That would prevent the snapshots from failing, no matter how many stars the repo gets.
If for whatever reason you cannot update your version up to 1.20, you can also "fake" the element with the evaluate() function, from changing the text before you take the snapshot to a fixed text (with the innerHTML property) or even making the element itself disappear changing its visibility with the setAttribute property. It's all about getting creative on this regard.
I know the question is old, but maybe someone will find the answer useful. What we did to go around the issue is inject css to hide the time stamps:
await page.addStyleTag({
content: `
.timestamp { display: none !important; }
`})
You just need to find the selector for the timestamp and use this code to hide it.

Cypress wait for table to load

I'm trying to test and click the table row that appears after I type text in the input component.
The table loads after delay (after getting response from external API). What woroked is using timeout that waits until certain element is loaded:
cy.get('[data-cy=searchBar]').type("Name")
cy.get('[data-cy=dataTable]').get('tbody').contains("td", "Result of name search", {timeout: 15000}).click()
So cypress waits until there is such row with given value, but the value my change and wont always be the same so is there a way to do exatcly same thing as above but selecting second row after table loads? (by default there are no items in the table)
I tried using this:
cy.get('[data-cy=searchBar]').type("Name")
cy.get('[data-cy=dataTable]').get('tbody').get("tr").eq(2, {timeout: 15000}).click()
But it seems cypress loads the table after checking for the second tr which fails the test.
See Cypress - how to wait for second of two elements to appear, you can add a should() to check the row length
cy.get('[data-cy=dataTable]')
.find('tbody tr') // ignore thead rows
.should('have.length', 3) // retries above cy.find() until true
.eq(2)
.click()
I'm not sure if you want to click the row (tr) or the cell (td). Looking at your first example (the one that works), it's the cell you want to click.
So you can add a cell selector
cy.get('[data-cy=dataTable]')
.find('tbody tr') // ignore thead rows
.should('have.length', 3) // retries above cy.find() until true
.eq(2) // take 3rd row
.find('td').eq(5) // take 6th cell
.click()
Cypress requires parameter values to be in quotation marks also if you know exactly the text you will find I suggest the following approach that is working for me:
cy.get('[data-cy="searchBar"]').type("Name")
cy.contains('[data-cy="dataTable"] td', "Result of name search")
.should('be.visible')
.click()
One way to make sure that cypress waits till the timeout, is to add the nth location of tr inside cy.get(), something like:
cy.get('[data-cy=dataTable] > tbody > tr:nth-child(3)', {timeout: 15000}).click()

MPV player time format HH:MM:SS or HH:MM:SS:mmm

does anybody know, if it is possible to set default displayed time format including milliseconds in mpv.conf ?
Now I need click on time to switch to millisecnds, because option ,,timems'' from manual https://mpv.io/manual/master/ doesn't work.
Thanks for help
Peter
from window:
click the LEFT timestamp
from command:
mpv .. --script-opts=osc-timems=yes ..
or add in lua-settings/osc.conf:
timems=yes
mpv --osd-fractions --osd-level=2
or add to config
To toggle show - hide with keyboard, append to to input.conf:
o cycle-values osd-level 2 1
#^-- or any other key
yes, add the line osd-fractions to mpv.config. this will show milliseconds in the OSD (which will appear in mpv's terminal display).
if you want to see milliseconds in the OSC (in the video window), also add the line osd-level=2 to mpv.conf. this will add a status message with the OSD time display (which is now in milliseconds) to the top of the window.
Or you can click the time display on the video each time you load a video.

Looping a number count in Edge Animate

I am creating a banner in Adobe Edge Animate with a number count going from 0 to 1000, then slowly going to 1001... 1002... 1003... and then restarting/looping.
I have searched multiple online forums and I am using a code that I found in a previous post that works for the number count (see below), but I cannot get it to loop. Usually when I want to loop a banner I go to a specific time in the timeline and insert a trigger with
this.play (0);
This still loops the banner but not the loop count - it only displays the number 1000 until looping again. Any tips on how to go about this?
Here is link to my banner, when the flashing colors appear is when the banner is looping:
Banner
Here is the code I'm using:
var counter_delay = 0;
var max_count = 1000;
var present_count = 0;
var timer = window.setInterval(stepUp,counter_delay);
function stepUp(){
present_count++;
// Change the text of an element
sym.$("Text").html(present_count);
if(present_count==max_count)
clearInterval(timer);
}
The variables are not working like this. You have to set and get Variables in Edge.
On Composition Ready
sym.setVariable("variablename", 0);
Get Value
var myVariable = sym.getVariable("variablename");
Change Value and Set it again
myVariable++;
sym.setVariable("variablename", myVariable);
For your Loop i think you can use "onupdate" and just use: get variable, increase variable, set the Value for your Variable again.
Then, if your number is high enough, just set the variable to 0 again.