- thegoatboy
- Posts : 4
Join date : 2012-07-03
text input very flaky on Chromedriver
Tue Jul 03, 2012 8:14 pm
Hello all,
I am very new to using chrome driver, so please if you can offer assitance i would be very grateful.
I am trying to fill in some text input on a web based application.
I can navigate to the page I need, but the text input really doesn't seem to work correctly using webdriver.
I will break down my code here:
My issue is that the first name is added correctly (Barry in this case) but the input of the second name fails 99.99% of the time.
I've tried adding some Thread.sleep bits in and many other ideas but this always fails.
I've tried adding a driver.click() for the surname element, but again this also fails, unless I add around 2 -5 just to get it to choose the correct element.
Can anyone offer some assistance in what I can do to get a reliable text entry using the Webdriver?
I don't understad how some basic functionallity like this doesn't work in chromedriver.
Is there some way I can keep checking until the correct text has been inputted?
or do i need some kind of wait command before continuing?
I am using Windows XP as well as eclipse.
I am very new to using chrome driver, so please if you can offer assitance i would be very grateful.
I am trying to fill in some text input on a web based application.
I can navigate to the page I need, but the text input really doesn't seem to work correctly using webdriver.
I will break down my code here:
- Code:
WebElement firstName;
WebElement surName;
...
String firstNamePath = "//input[contains(@id,'txtFirstName')]";
String surNamePath = "//input[contains(@id,'txtSurname')]";
firstName = driver.findElement(By.xpath(firstNamePath));
firstName.sendKeys("Barry");
surName = driver.findElement(By.xpath(surNamePath));
surName.sendKeys("Parry");
My issue is that the first name is added correctly (Barry in this case) but the input of the second name fails 99.99% of the time.
I've tried adding some Thread.sleep bits in and many other ideas but this always fails.
I've tried adding a driver.click() for the surname element, but again this also fails, unless I add around 2 -5 just to get it to choose the correct element.
Can anyone offer some assistance in what I can do to get a reliable text entry using the Webdriver?
I don't understad how some basic functionallity like this doesn't work in chromedriver.
Is there some way I can keep checking until the correct text has been inputted?
or do i need some kind of wait command before continuing?
I am using Windows XP as well as eclipse.
- iautomate
- Posts : 8
Join date : 2012-06-06
Location : Bengaluru
Re: text input very flaky on Chromedriver
Wed Jul 04, 2012 11:24 am
Hi.
I tried similar to what you have tried on the yahoomail website using the chromedriver and it works perfectly fine everytime. My code is as below
public class yahoomail{
public static void main(String args[]) throws InterruptedException{
WebElement Emailid;
WebElement Password;
WebDriver wd = new ChromeDriver();
wd.get("http://www.yahoomail.com");
Emailid = wd.findElement(By.id("username"));
System.out.println(Emailid.getTagName());
Emailid.sendKeys("hello");
Thread.sleep(100);
Password = wd.findElement(By.id("passwd"));
System.out.println(Password.getTagName());
Password.sendKeys("abcd");
Thread.sleep(100);
wd.close();
}
I am not sure why its going wrong in your case , i only suspect that identifying the webelement is failing can you try accessing the webelement using its id or the classname instead of xpath and check whether its consistent.
I tried similar to what you have tried on the yahoomail website using the chromedriver and it works perfectly fine everytime. My code is as below
public class yahoomail{
public static void main(String args[]) throws InterruptedException{
WebElement Emailid;
WebElement Password;
WebDriver wd = new ChromeDriver();
wd.get("http://www.yahoomail.com");
Emailid = wd.findElement(By.id("username"));
System.out.println(Emailid.getTagName());
Emailid.sendKeys("hello");
Thread.sleep(100);
Password = wd.findElement(By.id("passwd"));
System.out.println(Password.getTagName());
Password.sendKeys("abcd");
Thread.sleep(100);
wd.close();
}
I am not sure why its going wrong in your case , i only suspect that identifying the webelement is failing can you try accessing the webelement using its id or the classname instead of xpath and check whether its consistent.
- thegoatboy
- Posts : 4
Join date : 2012-07-03
Re: text input very flaky on Chromedriver
Wed Jul 04, 2012 3:23 pm
It seems that it is down to the speed of the applicaiton running.
I can get it to work correctly by sending
surName.click();
Thread.sleep(600);
surName.click();
thread.sleep(600);
This works.
For example, the first click() does not always select the second box, so I had to click twice to get this to work.
If this wasn't included, it seemed the application would just plough through too quickly, and in my case, I am also adding DOB info for instance, and this info would be placed in the worng boxes.
it seemed that there wasn't just enough time to complete the data.
There may be some hidden script working in the background of the application I am testing, so the text input may be just too quick for webdriver when switching to new web elements.
does that make sense?
I can get it to work correctly by sending
surName.click();
Thread.sleep(600);
surName.click();
thread.sleep(600);
This works.
For example, the first click() does not always select the second box, so I had to click twice to get this to work.
If this wasn't included, it seemed the application would just plough through too quickly, and in my case, I am also adding DOB info for instance, and this info would be placed in the worng boxes.
it seemed that there wasn't just enough time to complete the data.
There may be some hidden script working in the background of the application I am testing, so the text input may be just too quick for webdriver when switching to new web elements.
does that make sense?
- iautomate
- Posts : 8
Join date : 2012-06-06
Location : Bengaluru
Re: text input very flaky on Chromedriver
Wed Jul 04, 2012 3:48 pm
I think its not a good strategy to add redundant statements like above and make it work , its not a clean solution. I think you need to root cause what exactly is going on and implement a reliable solution. This solution for me looks very unstable.
- thegoatboy
- Posts : 4
Join date : 2012-07-03
Re: text input very flaky on Chromedriver
Wed Jul 04, 2012 4:06 pm
I know what you mean
but at the moment I have no idea what's wrong.
I've seen other posts on the internet with the same issue, but no reliable solution.
but at the moment I have no idea what's wrong.
I've seen other posts on the internet with the same issue, but no reliable solution.
- iautomate
- Posts : 8
Join date : 2012-06-06
Location : Bengaluru
Re: text input very flaky on Chromedriver
Wed Jul 04, 2012 4:12 pm
For the time being you can go with this workaround but once you figure out the problem do post it here.
- How to get the tittle of a object (not window), bcz title holds the full text but inner text holds only 25 char of text (in RC and Webdriver)
- Selenium Automatically clears the text entered in text box-Dynamic Web Table(dgrid)
- chromedriver.exe does not start
- Unable to enter text into the Code mirro text box
- How to find the chromedriver executable in ruby language
Permissions in this forum:
You cannot reply to topics in this forum