Error while executing selenium code

0 votes

Hello, I am using selenium to find blogs on AWS Migration from amazon. I am getting the following error:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"partial link text","selector":"www.amazon.com/"}


Can someone help me with this?

Here is the code that I used.

System.setProperty("webdriver.chrome.driver","C:\\Users\\Sradha\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.com");
        driver.findElement(By.name("q")).sendKeys("AWS Migration");
        driver.findElement(By.partialLinkText("www.amazon.com/"));
        Thread.sleep(4000);

Can someone help me with this?
 

Dec 28, 2018 in Selenium by Sradha
• 1,720 points
63 views

1 answer to this question.

0 votes

Hey @Sradha, First thing that I would like to tell you is, Amazon.com is a retail website.

https://aws.amazon.com is the website that handles all aws related contents.

Second, you are just searching for the key word and not clicking on search button. That's the reason you are getting error saying unable to locate the element.

Here is the code that I have used, take a look. Hope this will serve the purpose

System.setProperty("webdriver.chrome.driver","C:\\Users\\Nabarupa_Das\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("AWS Migration",Keys.ENTER);
driver.findElement(By.partialLinkText("https://aws.amazon.com/")).click();
Thread.sleep(4000);
answered Dec 28, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,080 points
660 views
0 votes
1 answer

Selenium IDE Click button error while clicking on Play Recording

Your code looks OK and would work ...READ MORE

answered Jun 27, 2018 in Selenium by Samarpit
• 5,130 points
95 views
0 votes
1 answer

Firefox Error: “Your connection is not secure” while launching driver with Selenium 3.0.1 using Java

Download Firefox 55 beta and set capabilities.setCapability("acceptInsecureCerts", true); Here ...READ MORE

answered Sep 17, 2018 in Selenium by Meci Matt
• 9,420 points
329 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
603 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
903 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
589 views
0 votes
1 answer

Error: TestNG @BeforeClass initialization code not running before Test

Below will help: @BeforeTest: The annotated method will ...READ MORE

answered Jul 6, 2018 in Selenium by Samarpit
• 5,130 points
876 views