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();
Related
I wanted to make specific inputs go into another part of a site (e.g. https://myexamplesite.com/anotherpartofit.html)
And also make those specific inputs be the ones that someone saved it in.
An example of what I think would work is: Get value from input 1 from /apartofit.html and put it in input 2 at /anotherpartofit.html and make it non-editable
If it needs to use a database, I would prefer if you could help me with firebase (Google's Database). But in my knowlege, it probably needs to use javascript, so I'll be tagging it, if it doesn't, let me know!
in visual studio or notepad or every offline web creating spaces you can't but if you buy a domain or simple , online site , you have to crate a page and get the link of that page then open another page create a button set the button's href to link of pervious page finally hit the button !
I'm trying to write a google chrome console script for WhatsApp Web which logs user's online statuses for later analyzation. I managed to define a function, which extracts the online status from the innerHTML, however this works just for one person at a time (since only this person's HTML is active and loaded). I had the idea for the script to switch through the user tabs (at the left of the page) and each time check the innerHTML for the online status. I tried the .click function, but couldn't figure out what to define as a click target... Maybe there is an even better way to solve this? Many thanks. 1: click on contact 2: check status 3: click on next contact 4: check status etc.
You dont have to click one by one. There are scripts like LoranKloeze and others on github doing that for you using timed functions. If you even have little javascript experince, you can understand the code and change it to your needs.
I have one scenario that in first website I have a link and second website have some jQuery alert.
What I want is that by clicking the link in first website alert will show in second website without reloading any page. Both websites are open in different machines.
Language of websites: PHP
You have 2 options:
Long-polling: Basically, whenever your button is clicked, you change something in the server, e.g you change a column in your database. And all the while, in your second page (the one you want to make the alert), you have a long-lived connection to another server-side file that constantly checks the value of that column in the database, and whenever you detect a change (which reflects the click), you return something to your JQuery (I implemented that using a while loop and the sleep function in PHP.
Websockets, in PHP, this means Ratchet.
For your case, I recommend the first approach, much simpler and easier to implement. I would use websockets for something like instant-messaging.
I have a fragment page (jsff) with a numeric keyboard based on buttons surrounded by a client listener which invoke a java script function; every time I click a number it refresh an input text with the value concatenated. I implemented that with JavaScript. Why with JavaScript? Because of the delay using partial triggers showing the value in the input text.
When I test it in the server it works very fine. I click every button and do have a little delay, but It works for the requirements of the develop.
Now, when I insert that fragment inside another jsff which have several components, the result isn't the same. I click every button, and the value is displayed in the input text very fast, but, the button I clicked takes between one and two second to reload for been clicked again. I don't understand what is happening.
Could anyone help me?
Thank you very much.
In Oracle Community I was helped by Florin Marcus:
I quote the answer that works for me:
"Probably you are still propagating the event to the server. You can easily double-check this with a browser plugin like Firefox/Firebug, see if there is any server request being sent.
Normally, you will need to explicitly cancel the event from propagating to the server. For example, if you have a clientListener on a button, you do something like below:
function showPopupFromAction(actionEvent)
{
actionEvent.cancel();
//your logic here
}
"
I am trying to figure out the best way to acompish "unobtrusive" forms for a user (within a web app).
The purpose: keep user on the site by not asking to fill unnecessary form in. Ask for the details as only when such are needed.
The requrements are:
User should provide additional details only when it is required (email to receive notifications, login required for account page, save credit card details when checking out).
User should not leave the current page providing the additional details.
The implementation would be fairly easy if all requests would be AJAX ones. It would be easy to analyse the response (401 or so) and show the appropriate lightbox-form.
I do not see how it can be done "the right way" with plain anchors and form submits as in both cases the user actually leaves the page (by following the link or submitting a form) and there is no way to analyse the response on the client side.
Converting all links and forms to AJAX ones would be just silly.
The closest analog to what I want to achieve is the default Basic Authentication dialog in most of the browser. But obviously that just doesn't fit my requirements.
Any creative suggestions how to do that for non-AJAX requests?
Regards,
Dmytrii.
In a page sense, where "page" refers to what the user sees and not what the URL is, I only can think of following ways to update independent parts in a page with JavaScript (and thus Ajax) switched off:
Frames
Iframes
Using held-open connections there are two more ways to update a page, however these do not work reliably in all cases:
Animated GIF
CSS DIV tags with absolute positioning.
Note that this needs that your Server can keep open a session for each person looking at the page, which can be thousands. If this does not work the only possible workaround is with FRAMEs and automatic refresh, which is somewhat clumsy.
As I think that you do not want to use Frames and you do not want to render animated GIFs, I explain the CSS DIV way:
When you load the page you do not finish loading it. Instead the connection is kept open by the web server and the script handling the connection waits for additional information to arrive. When there is additional data, this is sent to the browser by encapsulating it into additional DIV tags which can overwrite other parts of the page.
Using "style" in the DIV tag and CSS position:absolute these can overwrite other information on the page like a new layer. However you need either position:absolute or must add this data to the end of the page.
How does this work with forms?
Forms usually have a known size so you can put them into IFRAMEs. These IFRAMEs get submitted to the webserver. The script there notifies the other script that new data must be output, so the waiting script renders the response and displays it in the page while the script which took the submit redisplays the form with fresh values only.
How does this work with 404 and anchors?
I don't really know because this must be tested, but here is a hint how I would try to implement this:
We have 2 issues here.
First the URL must not point to other pages but back to a server script again, so the href is under control. This script then notifies the waiting script to update the page accordingly, for example by retrieving the page and sending it to your browser. The script can check for 404 as well.
Second you must hinder the browser to switch the page when clicking on the anchor. This probably involves some clever tricks using CSS, target and server side status codes (like "gone" or redirect to the current page, whatever) to keep the browser from switching the page. I am not completely sure if that works, but if you remember download pages, these show URLs which do not switch the page but have an effect (downloading the file). That's where to start to try to hack browsers not leaving the current page without using JavaScript.
One idea not followed here is not keeping the connection of the page open but the CSS file and send new css information to the browser which then "fills in empty stubs" using the CSS way. But I doubt that this works very well, most browsers probably will parse the CSS only after loading finished, but perhaps I am wrong.
Also note that keeping a connection open never finishes the page loading, so you will see the busy-logo spinning all the time, which is unavoidable with this technique.
Having said this all I doubt you get around JavaScript.
What I wrote here is very difficult to do and therefor usually is not used because it scales badly. And it is a lot more difficult than using JavaScript alone (that's why I explained it).
With proper AJAX it is much more easy to reach your goal. Also note that you do not need to change your page source much, all you need is to add a script which augments the page content such, that for example forms suddenly use AJAX instead of a direct POST with re-rendering the page. Things which cannot be detected easily then need some hints in the tags such that the tag scanner knows how to handle the tag. The good thing then is, that with JavaScript switched off your page still works - however it then "leaves the page".
Normal HTML just was not designed to create application-like web pages like we want to see today. This all was added using JavaScript.
About popup forms
The Basic-Auth-Handler reloads the page after the user enters something into this dialog, only if cancel is hit the current page is displayed.
But there are two ways to present additional query-popups in a page using JavaScript:
The first one is the javascript "prompt", like in following example:
http://de.selfhtml.org/javascript/objekte/anzeige/window_prompt_vor.htm
(Click on the "Hier").
The second one is "JavaScript forms" which are like popups within an HTML-page.
However I consider popups to be far too intrusive and bad design.
Ajax and JavaScript is the easiest way
Unfortunately using JavaScript is never easy, but if you think JavaScript is improper or too difficult, there is no other technique which is easier, that's why JavaScript is used everywhere.
For example your page onload-Script can cycle through all Anchor-Tags and modify them such, that clicking on them invokes a function. This function then must do something clever.
Same is true for Forms. Fields which can be modified (like the user's eMail address) then have two views, on is visible, the other one hidden. The hidden one is a form. Clicking on the eMail address then switches the view (disables the first div and enables the second), such that suddenly instead of the eMail address a text form field is there containing the eMail address. If you click on the "OK" button the button changes the look into a spinner until the data is submitted, then the view switches back to the normal one.
That's the usual way to do it using JavaScript and Ajax. And this involves a lot of programming until it works well.
Sorry for not shortening this post and missing code snippets, I am currently lacking time ;)
Hidden iframe.
Set target attribute of the form to the name of the iframe. use the onload event of the iframe to determine what is the response.
Or, if you really dont like any javascript, don't hide the iframe and instead present it in a creative manner.
CSS to hide an element
#myiframe { position:absolute; left: -999em; display: none; visibility: hidden; }
But normally, display: none is enough. This is just an overkill.