Does anyone know how I can dial a number using javascript? I've tried the following:
window.location.href = 'tel:7178081998';
The button registers a click but doesn't do anything in the ios environment.
I'm running into an issue where my "tel" links do not work because of a script that I have (FastClick). I've tried everything I can think of which is why I am at where I am.
Thoughts?
555-867-5309 This should work.
If need put a pop up dialog to ask user " Are you sure you want to call" Just in case s/he clicked it unintentionally.
<a id="call" href="">555-867-5309</a>
Use call id to open a dialog, on click of ok, put data dynamically to href attribute.
Sounds like a sandbox issue. Why not break out of the restriction with an iframe? Dynamically add it to the DOM and have it dial the number.
Adding IFRAME to DOM by Javascript
Related
I have my website set to a foreign language so that when Cypress clicks on the contact button or any button with href tag on my website, it should have sent me to the foreign version of that page but instead, it sends me to the english one. I cannot replicate this when I try to do it by hand.
I'm testing my website, salaenrollment.com, to make sure that if I switch the language on the website to a foreign language, it doesn't switch back when I click around to the contact and such.
cy.visit('https://salaenrollment.com/')
cy.contains('ភាសាខ្មែរ').click()
.url().should('include', '/kh')
cy.contains('ទំនាក់ទំនង').should('have.attr', 'href', '/kh/contact')
.click()
Everytime I test it with cypress, the language always switches but when I try to replicate it manually, I can never get it to switch. I wrote the code on cypress as simple as possible and I manually set wait times in the code but nothing works. About 90% of the time, when I test with cypress, the language doesn't switch. There is nothing wrong with the website and there are no errors.
What should happen is that cypress will enter the website, change the language, click on the contact button and the contact page will be in the foreign language. The cypress test should match a manual test.
probably you need to add some waiting time because your page its reloaded after switching the language maybe you need to check if your element already appear in the Dom with should('be.visible') this will add some waiting time by trying to check if the element is ready .
cy.visit('https://salaenrollment.com/')
cy.contains('ភាសាខ្មែរ').click()
.url().should('include', '/kh')
cy.contains('ភាសាខ្មែរ').should('be.visible')
cy.contains('ទំនាក់ទំនង').should('have.attr', 'href', '/kh/contact')
.click()
your selectors is also wrong please try this (it works in my local setup):
cy.visit('https://salaenrollment.com/')
cy.get('.language').click()
.url().should('include', '/kh')
cy.get('.language').should('be.visible')
cy.get('.contact ').should('be.visible')
cy.get('.contact ').should('have.attr', 'href', '/kh/contact')
.click();
I'm trying to check if a button was pressed and then open a new html file, I'm using express.js app.get method to open all of my HTML files. So my question is how can I open a HTML file on the same window when I press a button?
You could but shouldnt. NodeJS is backend.
Also note, that NodeJS is no JavaScript as normally referred to.
It is written/programmed in JavaScript.
To do something on click you would need either a normal <a> tag if you just want to open a link or you use client-side JavaScript with an onlick handler to execute something after a user clicked on an element.
You can accomplish this using javascript embedded into the html like this:
<button onclick="window.location='http://google.com'">Click me</button>
you can also try window.open=url
please note that this isn't really using node, just javascript. this type of behavior belongs in the page.
I think this thread would help you :)
https://stackoverflow.com/a/33703429/4578393
it uses if statements to check if the button has been pressed
if(req.body.hasOwnProperty("butt1")){
console.log("butt1 clicked");
Taine
I'm trying to get the content of a site, but this content only appears when I click the 'Chart' link, which is a JavaScript command like this:
javascript:__doPostBack('fcc1$dgrC$ctl02$ctl00',''
from a element like this:
Chart
This is the site:
And this is what happens when you click on 'Chart':
You can see that the link doesn't change, so the only way to get the chart code is by somehow send that JavaScript command
How to find all the chart links?
How can I do a 'virtual click' on the chart links?
And after that, how to get the new html?
I really appreciate your help!
doPostBack just sets the __EVENTTARGET and __EVENTARGUMENT form fields and submits the form. Those ''s are just quotes BTW.
If those links are indeed "clicked" by javascript listeners, you may have trouble finding a real link to click.
Instead, you could use a tool to simulate a web browser in python and "click" on that link to get to the next page. The best one I've used is Mechanical Soup: https://mechanicalsoup.readthedocs.io/en/stable/introduction.html.
Im using Selenium to open a page. After I open the page, I want to click a some sort of refresh button. When I click it, Im getting this error:
ElementNotVisibleError: element not visible
This is the code I use to click the button:
driver.findElement(By.id(id)).click();
My guess is that the button goes not visible whenever it is pushed. And that maybe it starts off not visible as well. Cause it doesnt do a full page refresh.
Any way for selenium to check if something is visible, and maybe wait until it is?
Edit:
As it turns out, there are multiple buttons with the same ID. And the button I am trying to reach are way down. I tried to find the button with By.xpath, but I still couldnt find it. The way I did it, was to search for button by id, like this //button[contains(#id, 'abc')][1]. (Different number of course).
Selenium could not find the element, but I could find it with Chrome developer tools. Any suggestions?
Solution: 1 You can try using this code in a syso,
System.out.println("getting Page Source "+driver.getPageSource());
This method will return the entire page Source and you can check whether your button exists in the source or not. You can place the above code at several points in your function and check until you find the button in the source.
Solution: 2 In case your button does not exist in the source you will have to check and see whether the button is getting loaded in an iframe and if so you can use the following code and switch to the iframe and and then try finding the button,
driver.switchTo.frame(frameName);
In your case you could use Explicit wait to check when the element/button is clickable.
Try doing this
wait.until(ExpectedConditions.visibilityOfElementLocated(id))
I am trying to make a bookmarklet to allow me to select all my friends in the dialog to create an event on Facebook. Examining the source with Firebug shows the following:
The div container for each person gets a new class label of
selectedCheckable
when it it is clicked, So I have written this like of JS to try and select all the div's and give them this class:
$(".checkableListItem").addClass("selectedCheckable");
This works in selecting them, however when it comes time to press the "Save and close" button, the changes do not seem to have any effect in selecting all the friends to add to the event. It seems that FB has a different way of marking the friends that have been selected to add to the event. Would anyone be able to point me in the right direction so I can accomplish this? Thanks in advance, RayQuang :)
May I advise instead of making your own couldn't you just use one of these Greasmonkey scripts?
http://userscripts.org/scripts/search?q=facebook+invite&submit=
That's what I was doing and it was working for my events. Let me know if it works for you.