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

Selenium testing failing in Safari #37

Open
shadynasty opened this issue Aug 31, 2016 · 1 comment
Open

Selenium testing failing in Safari #37

shadynasty opened this issue Aug 31, 2016 · 1 comment

Comments

@shadynasty
Copy link

I'm facing issues while sending Keys to the custom date field via Selenium.

I'm using a Work Around to send fields into the custom date format.. It does not work any other Way!
This works on ALL browsers but facing Intermittent failures using Safari.

The Algo is..

  1. Split DD/MM/YYYY into Arr = [DD MM YYYY]
  2. Send 'a'
  3. Send the ith element of Arr[]
  4. Repeat 2 and 3.

Below is the Code snippet just to send date Keys.

public boolean sendDateKeys(By locator,String date, String msg1, String id, int index ) throws IOException{ //This is browser Sensitive

                    String msg2 = "Entered"; 
                    DebugPauseAfterStep();

                    String dob;
                    String srcFormat = "mm/dd/yy"  ; 
                    String dstFormat_all = "dd/mm/yyyy";

                    String elemDob =                      UtilFunctions.get().getAngVar(id);
                    System.out.println("the current date is "+ elemDob);
                    dob = UtilFunctions.convertDateFormat(date , srcFormat, dstFormat_all);
                    System.out.println("the converted date is "+ dob);

                    dob = UtilFunctions.convertDateFormat(CL.getTestDataInstance().getDOB(), srcFormat, dstFormat_all);

                    WebDriver wd = CL.GetDriver();
                    try {
                                UtilFunctions.sleepFor(1,"safari date field"); //TODO better is wait for value to be found.. 
                                wd.findElement(locator).sendKeys("a");
                                String currBoxVal = getAngVar(id); 
                                System.out.println(String.format("the target is %s and orignal is %s", dob, currBoxVal)); 
                                int i = 0 ; 
                                for (String s : dob.split("/")){

                                            wd.findElement(locator).sendKeys(s);
                                            if (isSafari()){
                                                        DebugPauseAfterStep();
                                                        wd.findElement(locator).sendKeys("a");
                                            }
                                            wd.findElement(locator).sendKeys("a");
                                            i++; 
                                }
                                myReport("Pass", msg1 + " " + msg2 + " Value is:"+ b(dob));
                                //                                              UtilFunctions.get().sendKeys(locator, s, "Date of Birth", "Entered");
                                return true; 
                    }catch(Exception e){
                                myReport("Fail", msg1 + " NOT" + msg2 + " Value is:" +  b(dob) );
                                e.printStackTrace();
                                return false; 
                    }
        }
@eight04
Copy link
Owner

eight04 commented Sep 1, 2016

I don't use selenium either safari.

How about to add some delay before sending each key?

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

No branches or pull requests

2 participants