M
M
magary42017-02-08 18:39:52
JavaScript
magary4, 2017-02-08 18:39:52

What is the best way to run selenium php or js tests?

Previously, there was little experience in writing tests through js. Now I tried to do it also within the framework of phpunit PHPUnit_Extensions_Selenium2TestCase,
but somehow writing getByClassName or click() in php looks a little perverse
. Are there any arguments in favor of something?
and another question in passing - how to determine whether it is possible to physically click on the button? want to check that it's visible, that it's not covered by another element that has a higher z-index, or that it's within the screen?
also with a modal window - how to check that the modal has appeared on the screen?
Thank you

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
emp1re, 2017-02-08
@emp1re

I wrote tests at
https://www.npmjs.com/package/selenium-webdriver
, it's convenient for me because my development environment + fastened the packages I needed.
I think the main fact should be the code convention in the team.
If by yourself and for yourself, then why not try something new.
Well, or make it depend on the task and your knowledge in the language and development environment.

D
Dmitry, 2017-02-08
@Sad_Bro

codeception.
You can check visibility like this

public function seePageHasElement($element)
    {
        $I = $this;
        try {
            $I->seeElement($element);
        } catch (\PHPUnit_Framework_AssertionFailedError $f) {
            return false;
        }
        return true;
    }

T
Talik, 2017-02-09
@Talik0507

and another question in passing - how to determine whether it is possible to physically click on the button? want to check that it's visible, that it's not covered by another element that has a higher z-index, or that it's within the screen?
also with a modal window - how to check that the modal has appeared on the screen?

1) Checking visibility can indeed be done through waiting, as Dmitry @Sad_Bro showed.
For selenium, checking visibility is checking clickability in fact.
I don’t know why this is necessary, but you can scroll to the desired element, Selenium has a set of methods.
If they are not enough, you can always turn to JS
Find this class.
for example:
List list = driver.findElements(By.cssSelector("modal"));
if (list.size() > 0){
-- code
} else {
-- code
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question