Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98494

Getting unwanted not secure web window on trying to perform any action on any web element on current webpage

$
0
0

Screenshot of my code output

I tried the below code to navigate to a browser enter url - https://www.opencart.com/index.php?route=cms/demo and perform click action on a web element. But on trying to perform this on any web element via my below mentioned step definition file, I am getting unwanted not secure web window along with my browser window where the URL got entered successfully. Please note that this is happening for any website I am trying to automate. Any help is appreciated. JAi Shree Ram and Dhanyawaad in advance.

package StepDefinitions;import org.openqa.selenium.*;import org.openqa.selenium.edge.EdgeDriver;import org.openqa.selenium.edge.EdgeOptions;import io.cucumber.java.Before;import io.cucumber.java.en.*;public class OpencartDemoNavigation {    private WebDriver driver;    @Before    public void setup()    {    // Setting up things for successful navigation to unsecured websites    EdgeOptions options = new EdgeOptions();    options.setAcceptInsecureCerts(true);    options.addArguments("--ignore-certificate-errors");    // Declaring webdriver element    driver = new EdgeDriver(options);    }    @Given("chrome browser is open")    public void chrome_browser_is_open() {        // Write code here that turns the phrase above into concrete actions        // throw new io.cucumber.java.PendingException();        System.out.println("Inside Step - Chrome browser is open");        // Get current project path        String projectPath = System.getProperty("user.dir");        // Display project path        System.out.println("The current project path is: " + projectPath);        // Set system property for chrome driver        System.setProperty("webdriver.edge.driver", projectPath +"/src/test/resources/Drivers/msedgedriver.exe");        // Maximize browser window        driver.manage().window().maximize();    }    @When("user enters opencart demo URL in the chrome address bar and hits enter")    public void user_enters_opencart_demo_url_in_the_chrome_address_bar_and_hits_enter() throws InterruptedException {        // Write code here that turns the phrase above into concrete actions        // throw new io.cucumber.java.PendingException();        System.out.println("Inside Step - User enters opencart demo URL in the chrome address bar and hits enter");        driver.get("https://www.opencart.com/index.php?route=cms/demo");        Thread.sleep(15000);        //driver.navigate().to("https://www.opencart.com/index.php?route=cms/demo");        //driver.findElement(By.xpath("(//a[text()='Features']/ancestor::nav/..//div[contains(@class,'container')]/..//a[text()='Features']")).click();    }//  @Then("user gets navigated to opencart demo landing page")//  public void user_gets_navigated_to_opencart_demo_landing_page() {//      // Write code here that turns the phrase above into concrete actions//      // throw new io.cucumber.java.PendingException();//      System.out.println("Inside Step - User gets redirected to opencart demo store landing page");////      // Get the web page title and display it//      String currentPageTitle = driver.getTitle();//      System.out.println("The current page title is: " + currentPageTitle);////  }//    @When("user clicks opencart demo storefront tab")    public void user_clicks_opencart_demo_storefront_tab() throws InterruptedException {        // Write code here that turns the phrase above into concrete actions        // throw new io.cucumber.java.PendingException();        System.out.println("Inside Step - User clicks opencart demo storefront tab");        // Click the web element after hover        driver.findElement(By.xpath("//a[text()='Features']/ancestor::nav/..//div[contains(@class,'container')]/..//a[text()='Features']")).click();    }//  @Then("user gets redirected to opencart demo store landing page")//  public void user_gets_redirected_to_opencart_demo_store_landing_page() {//      // Write code here that turns the phrase above into concrete actions//      // throw new io.cucumber.java.PendingException();//      //      System.out.println("Inside Step - User gets redirected to opencart demo store landing page");//      //      // Get the web page title and display it//      String currentPageTitle = driver.getTitle();//      System.out.println("The current page title is: "+currentPageTitle);//                      //      // Set the expected page title//      // String expectedPageTitle = "";//                      //      // Verify the page title//      // Assert.assertEquals("Page title didn't match", expectedPageTitle, currentPageTitle); //      //  }}

I am getting the following error inspite of the fact that, element locator is correct. I triedgetWindowHAndles, driver.switchTo(), driver.navigate.To(), but no use.

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[text()='Features']/ancestor::nav/..//div[contains(@class,'container')]/..//a[text()='Features']"}


Viewing all articles
Browse latest Browse all 98494

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>