-1

I've done all the portions using XPath but when I'm going to enter or post something on the wall then the error came like this::

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element:/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]/div/div[3]/div/div/div[2]/div[1]/div/div/div[1]/span[1]/a/span[1]

My rest of the code is::

driver.findElement(By.xpath("//*[@id=\"email\"]")).sendKeys("---");
Thread.sleep(1000);

driver.findElement(By.xpath("//*[@id=\"pass\"]")).sendKeys("----");
Thread.sleep(1000);

driver.findElement(By.xpath("//*[@id=\"loginbutton\"]")).click();
Thread.sleep(3000);

// -------------------------------------------------------------------------------------

driver.findElement(By.xpath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]/div/div[3]/div/div/div[2]/div[1]/div/div/div[1]/span[1]/a/span[1]")).click();
Thread.sleep(4000);

driver.findElement(By.xpath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]/div/div[3]/div/div/div[2]/div[1]/div/div/div/div[2]/div/div[1]/div/table/tbody/tr/td[6]/div/a/div")).click();
Thread.sleep(4000);


driver.findElement(By.xpath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]/div/div[3]/div/div/div[2]/div[1]/div/div/div/div[2]/div/div[1]/div/div[1]/div[2]/div/div/div/div/div/div/div/div/div/div/span/span")).sendKeys("Hello to the Future");
Thread.sleep(2000); 

Reply fast as if anyone know the issue

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • you are using absolute xpaths (starting from html). always use relatives xpaths. post the html content of the page and element you want to identify, we can help u in finding the relative xpath or any other locator – Naveen Kumar R B Feb 13 '18 at 06:19
  • Scrapping [_Facebook_](https://www.facebook.com/) is against the [_ToS_](https://www.facebook.com/legal/terms) and you are liable to be questioned and may even land up in [_Facebook Jail_](https://www.facebook.com/help/community/question/?id=804287426255468). Use _Facebook API_ instead. – undetected Selenium Feb 13 '18 at 06:27
  • Possible duplicate of [NoSuchElementExeption, selenium unable to locate element](https://stackoverflow.com/questions/48471321/nosuchelementexeption-selenium-unable-to-locate-element) – undetected Selenium Feb 13 '18 at 06:53
  • How I can find the relative paths -- Naveen Kumar R B – Rohail Qayyum Feb 13 '18 at 09:32
  • DebanjanB, I had done it before but know it's not working. so that's mean Facebook is not against the – Rohail Qayyum Feb 13 '18 at 09:34
  • DebanjanB, I had done it before back in November in 2017 & that's working at that time ................... Now it's not working... So I think it's mine error, not the Automation side problem or I break the law of facebook – Rohail Qayyum Feb 13 '18 at 09:38
  • I'm doing this just to start learning how to automate the system – Rohail Qayyum Jan 15 '21 at 12:23

1 Answers1

0

You are just trying to locate an element and click on it. Try using an enable check strong text

If (driver.findElement(...).isEnabled())
    { 
        driver.findElement(...).Click();
    }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352