Is it possible to expect a click to fail with testcafe?
I'm using testcafe studio.
After I hit a submit button on my page, I want a test to make sure that some text is no longer on the page.
What is the best way of doing that?
Thanks
I found one way of ensuring that the element wasn't on the page:
I used a t.notOk(Selector(mySelectorHere).count)
In your test scenario you can use exists Selector property:
Selector('h1').withText('Some text').exists
Related
what I am trying to do is that when I navigate to a certain page there I need to press certain key from the keyboard i.e. alphabets to perform an action on the webpage.
The scenario is:
1- Navigate to webpage
2- Press a specific alphabet from the keyboard
3- Page performs an action when this alphabet is pressed from the keyboard
Currently, I am not sure how can I achieve this with Cypress normally we can type in the input box etc but I just want to simulate the keypress on the webpage. Is there a way to do this with the help of trigger function? if so then how to do it?
Yes you can send the key strokes to in cypress
cy.get('input').type('{shift}{alt}Q')
cy.get('input').type('{enter}')
Maybe this helps:
https://sqa.stackexchange.com/questions/46912/how-to-simulate-a-simple-keypress-in-cypress
Also, check out the documentation for Trigger in cypress. Check out recipes too. maybe you'll find something helpful.
Yes, here's the official documentation by Cypress. Just use the key modifiers in the .type() method:
.type('{meta}{command}{cmd}')
I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing
I have a button that executes an Ajax request and then it successfully redirects to another page.
How do I assert that the redirected page was successfully reached?
I have a clickAndWait on the button. But after that..?
you can use verifyTextPresent command to verify a unique lable or text in the redirected page.by that way you can fix you have successfully reached the redirected page.
try like this
command : verifyTextPresent
Target : some unique text in the redirected page.
i think your problem can be fixed by this.
IDE has many assert commands. You can use any of the one and you can achieve the test scope(here the page is navigated or not).
Example:
command : assertTitle
Target : check the title of the page.
In the above he used verifyTextPresent it will check weather the text is present or not in the page and it will continue the next step. If you use assert commands it will proceed the next step when the assert step is passed. Otherwise it fails.
One thing you keep in mind, selenium won't wait for Ajax kind of loading, it will wait for the Page loading. So, you have to put Wait commands explicitly to finish the Ajax loading.
You can get moreassertions when you convert the selenese code into the preferred language and testing framework. You can see that option in the Option tab in the IDE.
For more info on AssertCommands in SIDE
I am using selenium to test a webapp, for which most of the selenium test cases are already written. I have no idea how it works, I just build the project and go to link provided in the browser and run the test start running and yes all the test are manually written not generated.
I am using ruby, and doing something like this for clicking a link/button in a javascript popup :
def methodName()
clickAndWait("<Id of the link in js popup that I want to click>")
assertText("<text I need to check>")
end
this method is then called in '.test' file, but never works for a javascript popup, for the rest its all good !
help !
Popups a lot of the time are in a different context, either a frame or a window. When you call assertText, Selenium ignores these. Use the switchTo function (not sure of exact syntax in ruby) to switch to the popup before calling assertText
In Ruby maybe we should use like this:
#driver.switch_to.alert.accept
I'm creating tests (in Firefox) for a web app.
Depending on what field the cursor is over, a different help screen will appear. But when creating tests for those help screens, i cant get Selenium to focus on the particular field i want.
I've tried using fireEvent, click, select, and type in order to get the focus to stay on the field i require in order to load that particular help screen but i've had no luck.
Does anyone have ideas on how this can be solved. Or how i can work around it?
You can use selenium2 AdvancedUserInteractions API:
Actions builder = new Actions(driver);
builder.moveToElement(someElement).build().perform();
if my understanding of your question is correct, you wanted to display different help screens for differnt elements,
o.k here it is, if the message of the screen is displayed as a tool tip and the styling is taken care by mouseover event
selenium.mouseOver(locator) and then [ Thread.sleep(1000) ] and then use
selenium.mouseOut(locator)
try with this.if you don't get it and if my understanding of your question is wrong please post it.
you must investigate how that screen is being is displayed. and try to post all that code