lundi 30 novembre 2015

How Selenium webdriver locate element with a http response full of javascript

I use selenium webdriver to speed up my testing. In my work our website will redirect to paypal for user to finish payment. However, I cannot make selenium webdriver to locate the email and password input field on paypal.

The sample paypal URL : http://ift.tt/1SsWKXA

A demo of my code may like this:

    WebDriver m_driver = new FirefoxDriver();
    String redirected_url = "http://ift.tt/1PpC7xE";

    m_driver.get(redirected_url);
    Thread.sleep(15*1000);
    WebElement we = m_driver.findElement(By.xpath(".//*[@id='email']"));
    we.sendKeys("login_email");
    we = m_driver.findElement(By.xpath(".//*[@id='password']"));
    we.sendKeys("login_password");
    we = m_driver.findElement(By.xpath(".//*[@id='btnLogin']"));
    we.click();

My problem:

With that code and on the paypal website, I always got an error message of 'no such element' found exception.

I can locate the element with firepath in firefox but I cannot make selenium webdriver work.

I know this error may be caused by the javascript in the whole page of the paypal login page. I just don't know how to handle this situation. Can you please help me with an answer?

Aucun commentaire:

Enregistrer un commentaire