0

I've taken a good look around, however haven't been able to find the specific answer i'm after; hoping someone is able to point me in the right direction.

I'm automating a PayPal checkout process with WebDriver 2.53 in Visual Studio 2015 using C# against the Firefox driver. My flow into PayPal is fine, being able to login through the sandbox environment. However when I get to the confirmation screen following the initial login, I appear to be unable to select the continue button.

enter image description here

My code is:

driver.SwitchTo().Frame(driver.FindElement(By.TagName("iframe")));
var emailAddressLogin = driver.FindElement(By.Id("email"));
emailAddressLogin.SendKeys("EMailAddress");
var password = driver.FindElement(By.Id("password"));
password.SendKeys("Password");
var login = driver.FindElement(By.Id("btnLogin"));
login.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
var ContinueButton = driver.FindElement(By.XPath("//*[@id=\"confirmButtonTop\"]"));
ContinueButton.Click();

Once it gets to the confirmButtonTop selection, I'm always returning:

An exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll but was not handled in user code. Additional information: Unable to locate element: {"method":"id","selector":"confirmButtonTop"}

I have tried to locate the button via XPath, ID etc but nothing seems to allow the selection and always returned with "Unable to locate element".

HTML

Has anyone had issues with the 'continue' button within the PayPal sandbox environment, or advise what i'm missing? I have tried to switch focus but this doesn't seem to work.

Shutey
  • 11
  • 5
  • 1
    Could it be that you have another iframe or you are not in the same iframe but in the main window? – lauda Sep 14 '16 at 14:10
  • I did think that and added 'driver.SwitchTo().Frame(driver.FindElement(By.TagName("iframe")));' before trying to locate and select the continue option; however to no avail. I will add the full HTML of the section i'm looking at to the main description – Shutey Sep 14 '16 at 14:28
  • Add the html with the section for this if possible. I have a test for paypal and I don't have any iframe in my case, but after login i make sure that i am logged in waiting for css selector "#contactInfo .confidential" and in my case for continue i click using css selector "#step #continue" – lauda Sep 14 '16 at 14:44
  • Should be added and linked (HTML) within the main description.I'm sure it does seem to be some form of switch focus/iframe type thing, but seem to be struggling to work out what i need to switch to. – Shutey Sep 14 '16 at 14:56

1 Answers1

0

Ok so having done a little more searching I have found that by adding the following to my code before the button selection to work:

driver.SwitchTo().Window(driver.WindowHandles.Last());

So the end code looked like:

driver.SwitchTo().Frame(driver.FindElement(By.TagName("iframe")));
var emailAddressLogin = driver.FindElement(By.Id("email"));
emailAddressLogin.SendKeys("EMailAddress");
var password = driver.FindElement(By.Id("password"));
password.SendKeys("Password");
var login = driver.FindElement(By.Id("btnLogin"));
login.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.SwitchTo().Window(driver.WindowHandles.Last());
var ContinueButton = driver.FindElement(By.XPath("//*[@id=\"confirmButtonTop\"]"));
ContinueButton.Click();

This was taken from Selenium webdriver selecting new window c# and thanks to joinsaad

Community
  • 1
  • 1
Shutey
  • 11
  • 5