xpath is not working

+3 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, 2020 in Selenium by ARUN
• 150 points
3,206 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, 2020 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,290 points
8,748 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,910 points
2,428 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,910 points
3,252 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 16, 2019 in Selenium by Raishul
3,598 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
• 28,140 points
1,854 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
1,936 views
0 votes
1 answer

Which exception is raised when an element is not found in an HTML DOM using XPath

Hey, A stale element reference exception is thrown in one of two cases If ...READ MORE

answered Jul 30, 2020 in Selenium by Sirajul
• 59,230 points
10,280 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP