T
T
Tatyana2015-10-01 23:09:19
JavaScript
Tatyana, 2015-10-01 23:09:19

Selenium test to check that the page is reloaded and not reloaded depending on the actions, how?

Please tell me how to implement such a test for single-page applications with a bunch of javascript (backbone):
if I am on the main page and click on the logo, nothing should happen on the page at all, no reloads, etc.;
if I am on the product page and click on the site logo, then I go to the main page
if I was on the main page. but on top I had a certain javascript form open, such as SignInPage, I click on the logo - the form closes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tatyana, 2015-10-07
@tdurova

js.ExecuteScript("window.MyWindow = \"hello\"");
string textOld = (string)js.ExecuteScript("return window.MyWindow");
mainPage.Header.ClickHomeButton();
string textNew = (string)js.ExecuteScript("return window.MyWindow");
textNew.ShouldBeEquivalentTo(textOld);

M
matperez, 2015-10-02
@matperez

1. Depending on the state, you can display the logo as a link with a picture or a simple span with a picture. In selenium, to check the status, look for a nested image nested in a span tag or in an a tag.
Also, the current state of the SPA is most likely displayed in the link, through some hash. Accordingly, it is possible to check whether the url has changed when clicked.
2. Selenium can check if there is an element on the page and if it is visible. Google the implementation for your specific webdriver api. Elements are selected by css or xpath - it's more convenient here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question