Questions with the Clear command

Asked

Viewed 46 times

0

Good evening, you guys. I’m new to the forum, so I apologize if you’ve already asked this question.

My doubt concerns the command .clear(); using the webdriver Selenium in eclipse.

Well, I’m automating a test on a form, and before I use the Ndkeys command, I’m using the clear. The problem happens when I run normal, the clear command is ignored and Sendkeys adds information in the field. But when I run in Debug mode, the code works normally.

I’ve tried to use WaitForElementClickable, and Thread.Sleep(3000) but it didn’t help.

public void preencherSolicitacao(String UF, String resultado, Boolean positivo) throws InterruptedException {
        SolicitacaoAssistenciaDto solicitacao = form.solicitacaoAssistenciaForm();

        if (positivo) {
            Thread.sleep(3000);
            inputName.clear();
            inputName.sendKeys(solicitacao.getName());

            Thread.sleep(1200);
            adrress.clear();
            Thread.sleep(1200);
            adrress.sendKeys(solicitacao.getEndereco());

1 answer

0

Good night. For what I researched in https://stackoverflow.com/questions/3249583/selenium-webdriver-i-want-to-overwrite-value-in-field-instead-of-appending-to-i and in https://stackoverflow.com/questions/10799794/how-to-delete-default-values-in-text-field-using-selenium/29173649,

They recommended pressing the Ctrl+A keys to select the text before setting a new value. element.sendKeys(Keys.chord(Keys.CONTROL, "a"), "55");.

An answer also suggested pressing the HOME key for the cursor to go to the beginning of the text, then pressing Shift+Enter to select all the text: element.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END), "55");.

I never worked with Selenium webdriver but I hope I helped.

I await your reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.