Tell me how to solve the problem. I use selenide / Java / TestNG / maven and sometimes, in the login form, selenide does not fully enter the login or password text, somewhere around 50% of the tests fall as it begins. I tried many options to solve this problem, check for correct login, but there is no way to check the correctness of the password, used JavaScript to enter the login and password, nothing helped. I decided to try using cookies, but I don’t know how to implement everything correctly. I really need help. Thanks in advance
- show your code, which is not until the end enters the text in the form - Senior Pomidor
- $ (LOGIN) .sendValue (“text”); $ (PASSWORD) .sendValue (“text”); $ (BTN) .click (); - vaznoe
- Each test passes without any problems, but in the test itself, if one test fell, then the selenide does not enter the text completely and the following tests fall without starting :( - vaznoe
- Can you give a link to the site? - Senior Pomidor
- Unfortunately, I can not, this is an internal application - vaznoe
2 answers
Here are a couple of options that I tried:
if ($(EMAIL).setValue(LOGIN).getText().equals(LOGIN)) { $(PASSWORD).setValue(PSSWD); $(SIGN_IN_BUTTON).click(); } =============================
WebElement login = (new WebDriverWait(getDriver(), 10)) .until(ExpectedConditions.presenceOfElementLocated(EMAIL)); login.sendKeys(LOGIN); WebElement password = (new WebDriverWait(getDriver(), 10)) .until(ExpectedConditions.presenceOfElementLocated(PASSWORD)); password.sendKeys(PSSWD); WebElement button = (new WebDriverWait(getDriver(), 10)) .until(ExpectedConditions.presenceOfElementLocated(SIGN_IN_BUTTON)); button.click(); Selenide.Wait().withTimeout(4000, TimeUnit.MILLISECONDS); If you are interested in a login through cookies, then the algorithm of actions is as follows:
We get a token. We send http request for API with a locker and a password.
The following is a link to your application.
After doing ala:
Cookie ck = new Cookie("name", "value"); driver.manage().addCookie(ck);
And overload the page.
That is, you need to investigate the API authentication request. And see what your application needs to authorize the user. For example, on my project it is not only a token, but also other entities. With this question, it is better to approach the person responsible for the UI and the authorization page.
I hope you helped! :)