简体   繁体   中英

Selenium Unable to enter Paypal Sandbox Details

I am trying to get my Selenium test to Paypal test Details in order to automate Paypal Testing

I can navigate to the Sandbox.Paypal page but once there I cannot get Selenium to Automate Email and Password entry and clicking the Login Button. I am writing in C# on Visual Studio.

My code currently for this step is

                    driver.Instance.SwitchTo().Frame("injectedUl");

                    By AtPaypal = By.CssSelector("#loginSection > div.pr.row-fluid > xo-title > h1");
                    new WebDriverWait(driver.Instance, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementIsVisible(AtPaypal));

                    var email = driver.Instance.FindElement(By.Name("login_email"));
                    email.SendKeys(Keys.Control + "a");
                    email.SendKeys("xxxxxxxxxx");

                    var Password = driver.Instance.FindElement(By.Name("login_password"));
                    Password.SendKeys(Keys.Control + "a");
                    Password.SendKeys("xxxxxxxxxx");

                    var Login = driver.Instance.FindElement(By.Id("btnLogin"));
                    Login.Click();

                    By Paypal = By.Id("confirmButtonTop");
                    new WebDriverWait(driver.Instance, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementIsVisible(Paypal));

                    var ContinueBtn = driver.Instance.FindElement(By.Id("confirmButtonTop"));

                    ContinueBtn.Click();

However this isn't working, any help greatly appreciated.

Regards

Richard

您可以尝试在密码字段中发送 Enter 键,而不是单击登录按钮。

Hey Richard I got this to work.

If you are not typing in the fields, you are not correctly getting to the iframe. If you run it through debug does it work? Just wondering if it is a timing issue. I would also use ID over Name.

The page object I just used the input id for the field.

Create a switchTo to to go to the iframe.

     public static void SwitchToIframe(string frameName)
    {
      _webDriver.SwitchTo().Frame(frameName);
    }

Piece it together...

    Driver.Goto("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-54365007M8453270M#/checkout/login");
        Driver.SwitchToIframe("injectedUl");
        
     var email = driver.FindElement(By.ID("email"));
                email.SendKeys("test@no.com");

                var Password = driver.FindElement(By.ID("password"));
                Password.SendKeys("xxxxxxxxxx");

                var Login = driver.FindElement(By.Id("btnLogin"));
                Login.Click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM