1

I am newbie to selenium.I want to reload the same url page after 2 minutes. i have tried following code but its not working:-

for($i = 0; $i < 7; $i++)
    {
        $this->webDriver->get($this->url);
        $this->webDriver->findElement(WebDriverBy::xpath('/html /body/div[1]/div/div[4]/button/svg/path[1]'))->click();
       // $this->webDriver->quit();
       // echo $this->webDriver->getTitle() . "\n";
        //$this->webDriver->navigate()->back();
    }
blitz
  • 21
  • 2
  • 4

1 Answers1

1

As per the code block you have shared the loop won't get completed as following line will throw an exception :

$this->webDriver->findElement(WebDriverBy::xpath('/html /body/div[1]/div/div[4]/button/svg/path[1]'))->click();

That is because, webDriver wouldn't be able to locate the webelement through the Locator Strategy you have adopted and possibly throw NoSuchElement as <svg> elements are from a different svg namespace.

Solution

You have to take help of a Locator Strategy to construct a proper Locator to identify and detect the <svg> element and then try to invoke click() method on it.

Here you can find a detailed discussion on Selenium WebDriver [Java]: How to Click on elements within an SVG using XPath

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • i have removed this line $this->webDriver->findElement(WebDriverBy::xpath('/html /body/div[1]/div/div[4]/button/svg/path[1]'))->click(); but still selenim didnot open the url again n again – blitz Feb 22 '18 at 11:48
  • `didnot open the url again` doesn't throw any light on whats wrong happening. Update the question with your current code trial and error stack trace. – undetected Selenium Feb 22 '18 at 11:50