i Have Same Skip Types Kept For 99 Products. When Need To That it Will Bring an Popup in That Popup i Need To Clik the Cancel Button Each Time When i on The Skip Buton it Will Given an Pop Like This.

popup

So i Used This . it is Up To a Point of Time and Throwing an Error.

My Code is

package Backendsite;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;

public class SkipTest {
    @Test
    public void f() throws InterruptedException {
        System.setProperty("webdriver.chrome.driver",
                "F:\New folder\chromedriver.exe");

        // Setting To Open Incoginoto Window
        ChromeOptions options = new ChromeOptions();
        options.addArguments("-incognito");
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        WebDriver chromedriver = new ChromeDriver(capabilities);

        chromedriver.manage().window().maximize();

        // Opening The WebSite
        chromedriver.get("xxxxxxxxxxx");

        chromedriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        Pomsite p1 = PageFactory.initElements(chromedriver, Pomsite.class);

        Select s1 = new Select(p1.getE1());
        s1.selectByVisibleText("xxxxxxxxxxxx");


        Thread.sleep(3000);

        List<WebElement> elements = chromedriver.findElements(By.xpath("//input[contains(@id, 'CustomPaging_GridView_gv_edit1_')]"));


        Thread.sleep(2000);

        for (Iterator<WebElement> iterator = elements.iterator(); iterator.hasNext();)
        {


            WebElement webElement = (WebElement) iterator.next();

            Thread.sleep(2000);

            webElement.click();

            Thread.sleep(2000);

            chromedriver.findElement(By.xpath("//button[text()='Cancel']")).click();
        }  

The Exception Error is ,

org.openqa.selenium.ElementNotVisibleException: element not visible

PS: Sometimes i Will Stale Element Reference Error.Please Help Me out Guys.



Source link https://sqa.stackexchange.com/questions/34480/why-my-code-is-not-working-when-i-click-on-the-same-button-for--

LEAVE A REPLY

Please enter your comment!
Please enter your name here