xpath is not working

+2 votes
package Basics;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByXPath;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Olx_Assignment {
public static void main(String[] args) throws InterruptedException  {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","D:\\SELENIUM DOWNLOADS\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.olx.in/");
WebElement wb = driver.findElementByXPath("//*[@id=\'footer\']/div[1]/div/section[3]/ul/li[2]/a");
wb.click();
Thread.sleep(3000);
// driver.get("https://www.olxgroup.com/search/all-functions/all-locations/all-brands");
WebElement wb1 = driver.findElement(By.xpath("//*[@id=\'root\']/div/div[2]/div/section[4]/div/div[1]/section/div/a[2]/div[1]/div"));
Thread.sleep(3000);
wb1.click();
WebElement wb2 = driver.findElementByXPath("//*[@id=\'root\']/div/div[2]/section/section[3]/div/div/div/a/span");
wb2.click();
}
}
Jan 21 in Selenium by ARUN
• 140 points
178 views
Hey Arun, Could you specify what error are you getting?

1 answer to this question.

0 votes
Try this,
public class SiblingAndParentInXpath {

    @Test

    public void testSiblingAndParentInXpath(){

    	WebDriver driver;
    	String driverPath = "C:\\geckodriver.exe";
    	System.setProperty("webdriver.gecko.driver", driverPath);
        driver = new FirefoxDriver();        
        
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://kuknus.com");
answered Mar 31 by anonymous
• 140 points

Related Questions In Selenium

0 votes
1 answer

findElement(By.xpath()) not working using Selenium WebDriver

element = findElement(By.xpath("//*[@test-id='test-username']"); element = findElement(By.xpath("//input[@test-id='test-username']"); (*) - any ...READ MORE

answered Apr 18, 2018 in Selenium by code_ninja
• 6,230 points
4,006 views
0 votes
1 answer

Selenium ChromeBrowser get() method is not working

Make sure you are passing a valid ...READ MORE

answered May 25, 2018 in Selenium by Samarpit
• 5,870 points
829 views
0 votes
1 answer
0 votes
1 answer

Xpath not working in firefox but working fine in chrome

Try to search above xpath in chrome ...READ MORE

answered Jul 17, 2018 in Selenium by Samarpit
• 5,870 points
1,429 views
0 votes
0 answers

How to hover element when action class is not working in my Selenium framework ?

When i am writing the code to ...READ MORE

Feb 15, 2019 in Selenium by Raishul
1,204 views
+1 vote
1 answer

Explicit Wait with Page Factory is not working as expected

Hey Tewadros, you can use implicit wait ...READ MORE

answered Oct 14, 2019 in Selenium by Abha
• 27,920 points
489 views
0 votes
0 answers

xpath search working on browser[firefox/Chrome] but not on Selenium python script.

Hi Team, I am getting below expception while ...READ MORE

Nov 14, 2019 in Selenium by ashutosh
• 120 points
465 views
0 votes
1 answer

Xpath element not found

You need to induce WebDriverWait with expected_conditions ...READ MORE

answered Mar 27, 2018 in Selenium by ned_crew
• 1,620 points
745 views