Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form.fill() doesn't clear text inputs before calling sendKeys() #84

Merged
merged 1 commit into from
Jun 19, 2015
Merged

Conversation

emaks
Copy link
Contributor

@emaks emaks commented May 29, 2015

    @Test
    public void test() {
        Map<String, Object> data = new HashMap<>();
        data.put("login", "email_login");

        MainPage page = new MainPage(new FirefoxDriver());

        page.open();
        page.fillLogin(data);
        Assert.assertEquals(data.get("login"), page.getLogin());
        page.fillLogin(data);
        Assert.assertEquals(data.get("login"), page.getLogin());
    }

    public class MainPage {
        @FindBy(css = "form[role=form]")
        private Form loginForm;

        WebDriver driver;

        public MainPage(WebDriver driver) {
            this.driver = driver;
            PageFactory.initElements(new ElementDecorator(this.driver), this);
        }

        public void open() {
            driver.get("http://www.yandex.ua/");
        }

        public void fillLogin(Map<String, Object> data) {
            loginForm.fill(data);
        }

        public String getLogin() {
            return loginForm.getWrappedElement().findElement(By.cssSelector("[name=login]")).getAttribute("value");
        }
    }

@artkoshelev
Copy link
Contributor

test this please

@artkoshelev
Copy link
Contributor

that's good, please squash this commits into one and we'll merge it

@aik099
Copy link
Contributor

aik099 commented May 29, 2015

Looks like a code duplication. We have similar issue with other element in past and it was solved there. I think that we should be using corresponding element methods, e.g. TextElement to set their value instead of fallback to sendKeys and similar methods.

@emaks
Copy link
Contributor Author

emaks commented Jun 4, 2015

please squash this commits into one

done

@artkoshelev
Copy link
Contributor

@emaks wouldn't this change brake filling TextArea elements?

@emaks
Copy link
Contributor Author

emaks commented Jun 7, 2015

@artkoshelev, please, see new implementation.
and I have one question: Why there are no exceptions in this cases: 1st, 2nd ?

@artkoshelev
Copy link
Contributor

i think it's better to use StringUtils.defaultString which is null-safe version of String

@artkoshelev
Copy link
Contributor

@emaks, and answering your question about exceptions, i don't know the reasons behind this implementation, but at least it works exactly as described in javadoc =)

@@ -61,4 +63,13 @@ public String getText() {
}
return enteredText;
}

public void fill(String value) {
// Returns sequence of backspaces and deletes that will clear element
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change comment style to multiline here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@artkoshelev
Copy link
Contributor

test this please

@emaks
Copy link
Contributor Author

emaks commented Jun 15, 2015

@artkoshelev Are there any additional problems with pull request?

@artkoshelev
Copy link
Contributor

@emaks i just need some time to made a final review

artkoshelev added a commit that referenced this pull request Jun 19, 2015
Form.fill() doesn't clear text inputs before calling sendKeys()
@artkoshelev artkoshelev merged commit 0d909e5 into yandex-qatools:master Jun 19, 2015
@artkoshelev
Copy link
Contributor

landed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants