I want to test the Ebay site login, without using Xpath
. It is not working, right now. I tried for hours to make this work. Please tell me what I am doing wrong and how to fix it.
This is what I am doing:
- Open Google website
- Search for “ebay” website
- Click on the appropriate result
- Go to http://www.ebay.com website
- Click on the “Sign in” link to navigate to the ebay login page
- Enter email address/password
- Click on Sign In button
- Verify your user name.
package Script;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class TestEbay_login {
@Test
public void ebay_login() throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Senani\\Downloads\\Programs\\geckodriver-v0.23.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//driver.get("https://www.google.com");
driver.navigate().to("https://www.google.com");
driver.manage().window().maximize();
driver.findElement(By.name("q")).sendKeys("ebay");
driver.findElement(By.name("btnK")).submit();
driver.findElement(By.cssSelector("a[href='www.ebay.com']")).click();
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("userid")).sendKeys("*******");
driver.findElement(By.id("pass")).sendKeys("*******");
driver.findElement(By.id("sgnBt")).click();
}
}
FAILED: ebay_login org.openqa.selenium.NoSuchElementException: Unable to locate element: a[href='www.ebay.com'] For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
update question how to find unique anything this element. Can anyone help me. I'm stuck in this code.
<a href="https://www.ebay.com/" ping="/url?sa=t&source=web&rct=j&url=https://www.ebay.com/&ved=2ahUKEwjDpP21_c_fAhWLLY8KHXYwB9gQFjAAegQIAxAC">
<h3 class="LC20lb">eBay: Electronics, Cars, Fashion, Collectibles, Coupons and More</h3>
<br>
<div style="display:inline-block" class="TbwUpd">
<cite class="iUh30">https://www.ebay.com/</cite>
</div>
</a>