1

Test case: Check box needs to be checked and corresponding drop down value needs to be selected.

Issue: Cannot click on the element as another element is overlapped on the required element. Error is

Element is not clickable at point (898.9500122070312, 16.5). Other element would receive the click:
Command duration or timeout: 76 milliseconds

public class ProfileCreation {

public static WebDriver driver ;

public static void main(String[] args) {

    WebDriver driver = new FirefoxDriver();

    JavascriptExecutor jse = (JavascriptExecutor)driver;

    String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime());

    System.out.println("Profile Name ===>"+ timeStamp );

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

    driver.get("http://suite.simplify360.com");

    driver.findElement(By.cssSelector(".form-login.first-input")).sendKeys("alexxm360@gmail.com");

    driver.findElement(By.id("login_password")).sendKeys("Simplify360@");

    driver.findElement(By.id("rp")).click();

    driver.findElement(By.linkText("Listen")).click();

    driver.findElement(By.xpath("//input[contains(@onclick,'createNewProfile();')]")).click();

    driver.findElement(By.xpath("//input[@id='dashboardName']")).sendKeys(timeStamp);

    System.out.println("Profile Name ===>"+ timeStamp );

    WebElement slider = driver.findElement(By.xpath("//*[@id='slider-range-max']/a[2]"));

    Actions move = new Actions(driver);

    Action action = (Action) move.dragAndDropBy(slider, 30, 0).build();

    action.perform();

    WebElement permissionDropDown = driver.findElement(By.id("actionPerm"));

    Select oselect = new Select(permissionDropDown);

    List <WebElement> elementCount = oselect.getOptions();

    //      System.out.println("Count of Options"+elementCount.size());

    int iSize = elementCount.size();

    // For priting the values in permission

    /*for(int i =0; i<iSize ; i++){

        String sValue = elementCount.get(i).getText();

        System.out.println("permissoin Values"+sValue);

        }*/

    oselect.selectByVisibleText("OPEN");

    oselect.selectByVisibleText("WARN");

    oselect.selectByVisibleText("BLOCK");

    if (driver.findElements(By.cssSelector("a.cb-enable.selected")).size() > 0 ) {

        driver.findElement(By.xpath("//span[contains(.,'Off')]")).click();

    } else {

        driver.findElement(By.xpath("//span[contains(.,'On')]")).click();

    }

    if(driver.findElements(By.id("reassignPeriodMins")).size() > 0){

        WebElement caseAssociateMin = driver.findElement(By.id("reassignPeriodMins"));

        Select timeSelect = new Select(caseAssociateMin);

        WebElement firstSelectedOption = timeSelect.getFirstSelectedOption();

        System.out.println("Default Selected Time"+firstSelectedOption.getText());

        timeSelect.selectByVisibleText("45");

    }

    if(driver.findElements(By.id("replySetting")).size() > 0){

        WebElement replySetting = driver.findElement(By.id("replySetting"));

        Select replyType = new Select(replySetting);

        WebElement firstSelectedOption = replyType.getFirstSelectedOption();

        System.out.println("Default Selected Time"+firstSelectedOption.getText());

        replyType.selectByVisibleText("REPLY");

        replyType.selectByVisibleText("REPLYALL");

    }

    System.out.println( "checkboxes" + driver.findElements(By.className("shareCheck")).size());

    int sizeOfUsers = driver.findElements(By.className("shareCheck")).size();


    for (int i = 1; i <= sizeOfUsers; i++) {

        boolean fname = driver.findElement(By.xpath("//*[@id='basketusers']/tbody/tr["+ i +"]/td[3]/input")).isEnabled();

        if (fname == false){

            String disblaedEmailID = driver.findElement(By.xpath("//*[@id='basketusers']/tbody/tr["+ i +"]/td[2]/div")).getText();

            String loginEmailId = "nagarjun.reddy@in-rev.com";

            if( disblaedEmailID == loginEmailId){

                System.err.println("Check Box is disabled ====>"+disblaedEmailID);

            }

            System.err.println("i value==>"+ i);

            i++;

            System.err.println("selected email id will be =="+ driver.findElement(By.xpath(".//*[@id='basketusers']/tbody/tr["+i+"]/td[2]/div")).getText() );

            //ISSUE IS HERE. CANNOT MOVE TO THE REQUIRED ELEMENT 

            jse.executeScript("arguments[0].scrollIntoView(true);",driver.findElement(By.xpath(".//*[@id='basketusers']/tbody/tr["+i+"]/td[2]/div")));

            driver.findElement(By.xpath("//*[@id='basketusers']/tbody/tr["+ i +"]/td[3]/input")).click();

            Select roleSelect = new Select(driver.findElement(By.xpath(".//*[@id='basketusers']/tbody/tr["+i+"]/td[4]/select")));

            System.err.println("First selected role ====>"+ roleSelect.getFirstSelectedOption().getText());

            roleSelect.selectByVisibleText("PROFILE AGENT");

            System.err.println("Changed role ====>"+ roleSelect.getFirstSelectedOption().getText());

        }

        //          System.err.println(  driver.findElement(By.xpath("//*[@id='basketusers']/tbody/tr["+ i +"]/td[3]/input")));

    }

    //      driver.findElement(By.xpath("//input[@value='Next']")).click();

}

}
HiDeoo
  • 10,353
  • 8
  • 47
  • 47
Nagarjuna Reddy
  • 759
  • 9
  • 19
  • 39
  • Make sure that if you are testing on a production environment you will use a test/fake email and password and even give a fake URL, more important is the html code of the element with the error and the full error stack-trace. – lauda Aug 09 '16 at 07:22
  • Can you provide more detailed error? does it says what element receives the click? have you tried to hide the element or to scroll to top or focus/click on another element? If you can please provide a print-screen with the overlap issue. – lauda Aug 09 '16 at 07:25
  • @lauda: Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (898.9500122070312, 16.5). Other element would receive the click: tried scroll to element code jse.executeScript("arguments[0].scrollIntoView(true);",driver.findElement(By.xpath(".//*[@id='basketusers']/tbody/tr["+i+"]/td[2]/div"))); – Nagarjuna Reddy Aug 09 '16 at 07:34
  • You need to check manually how to make it visible: click on another element, scroll on top. See what is easier and manually works and and implement it. – lauda Aug 09 '16 at 07:45
  • @lauda not aware of the methods to make the elements manually visible. my assumption was after using the "scrollIntoView", element should be visible. – Nagarjuna Reddy Aug 09 '16 at 08:13
  • Is not a method to do it manually, i meant to test it manually and not with automation and check what happens, maybe scrollIntoView does not help and you need to do something else, some other action. – lauda Aug 09 '16 at 08:19
  • @lauda can you please help me with an answer, preferably the code – Nagarjuna Reddy Aug 09 '16 at 08:31
  • In order to tell you what you need to do, i need to see what happens, to see the page and the html. You can try to scroll to top, please see http://stackoverflow.com/questions/12293158/page-scroll-up-or-down-in-selenium-webdriver-selenium-2-using-java – lauda Aug 09 '16 at 08:51
  • @lauda yes i'm aware of this simple scroll with no logic in it. but trying to make the script better. – Nagarjuna Reddy Aug 09 '16 at 09:03
  • Provide some screen with the overlap and some html code with the element that is overlapped and the element that overlaps. In order to make the script better you can try to refactor in methods like: openHomepage, loginWith, setPermissions etc., so smaller methods that you can call in a test. – lauda Aug 09 '16 at 09:49
  • @lauda please feel free to execute the code if you are planning to give an answer. Comment is added where the issue could be – Nagarjuna Reddy Aug 09 '16 at 10:40

1 Answers1

0

Try adding a scroll up like this.

jse.executeScript("window.scrollBy(0,-250)", "");

This will just make the chekbox not to hid eunder navbar. i tried locally and it worked.

HemChe
  • 2,249
  • 1
  • 21
  • 33
  • help me in understanding the above statement. are we saying to scroll up the page. Still getting same error in my test run. – Nagarjuna Reddy Aug 09 '16 at 19:17
  • i have executed your code locally and it was able to click the checkbox after adding a scroll as above. and i value was 4. Let me know if you need more help. – HemChe Aug 10 '16 at 09:56