简体   繁体   English

Selenium 无法进入 Paypal 沙盒详细信息

[英]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我正在尝试将我的 Selenium 测试转换为 Paypal 测试详细信息,以便自动执行 Paypal 测试

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.我可以导航到 Sandbox.Paypal 页面,但是一旦出现,我就无法让 Selenium 自动输入电子邮件和密码并单击登录按钮。 I am writing in C# on Visual Studio.我在 Visual Studio 上用 C# 编写。

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.如果您没有在字段中键入内容,则您无法正确访问 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.我也会在名称上使用 ID。

The page object I just used the input id for the field.我刚刚使用该字段的输入 id 的页面对象。

Create a switchTo to to go to the iframe.创建一个 switchTo 以转到 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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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