1

I am trying to Login to Ebay site using Selenium. I have successfully identified the user name and password Text boxes using Xpath (and validated the xpaths using the Firefox Eval tool in Firebug).

public class LoginTestCase{     
    @Test
    public void LoginEbay() throws InterruptedException 
    {
        System.setProperty("webdriver.gecko.driver", "D:\\selenium_library\\geckodriver-v0.17.0-win64\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();

        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

        //navigate to Ebay
        driver.get("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=https%3A%2F%2Fwww.ebay.com%2F");

        Thread.sleep(20000);
        // Enter user name , password and click on Signin button
        driver.findElement(By.xpath("//input[@placeholder='Email or username' AND @type='text']")).sendKeys("####@###");            
        //driver.findElement(By.xpath("//input[@placeholder='Password' AND @class='fld']']")).sendKeys("####");
        driver.findElement(By.id("sgnBt")).click();
    }
}

I am getting the below warning after which the script Fails.

1499976357508   geckodriver INFO    Listening on 127.0.0.1:41809
1499976358783   geckodriver::marionette INFO    Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"]
1499976367184   Marionette  INFO    Listening on port 62686
Jul 13, 2017 4:06:20 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript warning: https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=https%3A%2F%2Fwww.ebay.com%2F, line 170: unreachable code after return statement
3

The warnings you see on the console are there because of the DEBUG logging turned on by default, they have nothing to do with the real problem as it turns out.

Your XPath expression is not valid, AND should be lower-cased:

//input[@placeholder='Email or username' and @type='text']
                                         ^^^HERE

As a side note:

  • you should not be using hardcoded time delays to tackle timing issues - use WebDriverWait and specify what are you waiting for explicitly
  • you can use better locators

Improved ebay logging in code snippet:

//navigate to Ebay
driver.get("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=https%3A%2F%2Fwww.ebay.com%2F");

WebDriverWait wait = new WebDriverWait(driver, 20);

// Enter user name , password and click on Signin button
WebElement form = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#mainCnt #SignInForm")));

form.findElement(By.cssSelector("input[type=text][placeholder='Email or username']")).sendKeys("####@###");
form.findElement(By.cssSelector("input[type=password]")).sendKeys("test");

form.findElement(By.id("sgnBt")).click();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.