Unable to click image button











up vote
0
down vote

favorite












I am trying to click an image button, but i am getting org.openqa.selenium.NoSuchElementException. I even Checked if the element is present in any iframe by iterating through the frames. It is not present in any of the frames. Am i missing something?. Can someone please help me out with this.



Below is the code i am trying:



WebDriverWait wait2 = new WebDriverWait(driver,30);  
WebElement image = wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']")));
actions.click(image).build().perform();


Exception i am getting:



Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 45 seconds waiting for visibility of element located by By.xpath: //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'W1856237', ip: '192.168.43.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at com.ExpTestcases.TestOne.main(TestOne.java:105)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']"}
(Session info: chrome=70.0.3538.77)


And this is the html code for the image button:



<table role="button" aria-label="User Prompt Input" aria-pressed="false" title="User Prompt Input" style="display: block; cursor: pointer;" false"="" margin:0px"="" id="vertBar_leftPaneW_icon_3" class="" cellspacing="0" cellpadding="0" border="0" aria-labelledby="ariaLabelledBy_vertBar_leftPaneW_icon_3" tabindex="0">
<tbody>
<tr valign="middle">
<td id="iconleft_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
<td id="iconmid_vertBar_leftPaneW_icon_3" align="center" style="height:35px;" class="">
<div style="overflow:hidden;height:31px;" valign="middle">
<div id="IconImg_vertBar_leftPaneW_icon_3" class="imo" style="width:31px;height:31px;background-image:url('images/main/vertbar_icons.png');background-position:-1px -127px;margin-top:2px;cursor:pointer"></div>
</div>
</td>
<td id="iconright_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
</tr>
</tbody>
</table>


Xpath trials:




  • //table[@aria-label="User Prompt Input"]


  • //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']


  • //table[@aria-label="User Prompt Input"]/@title


  • //tr//table[@aria-label="User Prompt Input"]/@title











share|improve this question
























  • if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
    – Fabrice Zaks
    Nov 10 at 21:24

















up vote
0
down vote

favorite












I am trying to click an image button, but i am getting org.openqa.selenium.NoSuchElementException. I even Checked if the element is present in any iframe by iterating through the frames. It is not present in any of the frames. Am i missing something?. Can someone please help me out with this.



Below is the code i am trying:



WebDriverWait wait2 = new WebDriverWait(driver,30);  
WebElement image = wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']")));
actions.click(image).build().perform();


Exception i am getting:



Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 45 seconds waiting for visibility of element located by By.xpath: //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'W1856237', ip: '192.168.43.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at com.ExpTestcases.TestOne.main(TestOne.java:105)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']"}
(Session info: chrome=70.0.3538.77)


And this is the html code for the image button:



<table role="button" aria-label="User Prompt Input" aria-pressed="false" title="User Prompt Input" style="display: block; cursor: pointer;" false"="" margin:0px"="" id="vertBar_leftPaneW_icon_3" class="" cellspacing="0" cellpadding="0" border="0" aria-labelledby="ariaLabelledBy_vertBar_leftPaneW_icon_3" tabindex="0">
<tbody>
<tr valign="middle">
<td id="iconleft_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
<td id="iconmid_vertBar_leftPaneW_icon_3" align="center" style="height:35px;" class="">
<div style="overflow:hidden;height:31px;" valign="middle">
<div id="IconImg_vertBar_leftPaneW_icon_3" class="imo" style="width:31px;height:31px;background-image:url('images/main/vertbar_icons.png');background-position:-1px -127px;margin-top:2px;cursor:pointer"></div>
</div>
</td>
<td id="iconright_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
</tr>
</tbody>
</table>


Xpath trials:




  • //table[@aria-label="User Prompt Input"]


  • //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']


  • //table[@aria-label="User Prompt Input"]/@title


  • //tr//table[@aria-label="User Prompt Input"]/@title











share|improve this question
























  • if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
    – Fabrice Zaks
    Nov 10 at 21:24















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to click an image button, but i am getting org.openqa.selenium.NoSuchElementException. I even Checked if the element is present in any iframe by iterating through the frames. It is not present in any of the frames. Am i missing something?. Can someone please help me out with this.



Below is the code i am trying:



WebDriverWait wait2 = new WebDriverWait(driver,30);  
WebElement image = wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']")));
actions.click(image).build().perform();


Exception i am getting:



Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 45 seconds waiting for visibility of element located by By.xpath: //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'W1856237', ip: '192.168.43.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at com.ExpTestcases.TestOne.main(TestOne.java:105)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']"}
(Session info: chrome=70.0.3538.77)


And this is the html code for the image button:



<table role="button" aria-label="User Prompt Input" aria-pressed="false" title="User Prompt Input" style="display: block; cursor: pointer;" false"="" margin:0px"="" id="vertBar_leftPaneW_icon_3" class="" cellspacing="0" cellpadding="0" border="0" aria-labelledby="ariaLabelledBy_vertBar_leftPaneW_icon_3" tabindex="0">
<tbody>
<tr valign="middle">
<td id="iconleft_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
<td id="iconmid_vertBar_leftPaneW_icon_3" align="center" style="height:35px;" class="">
<div style="overflow:hidden;height:31px;" valign="middle">
<div id="IconImg_vertBar_leftPaneW_icon_3" class="imo" style="width:31px;height:31px;background-image:url('images/main/vertbar_icons.png');background-position:-1px -127px;margin-top:2px;cursor:pointer"></div>
</div>
</td>
<td id="iconright_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
</tr>
</tbody>
</table>


Xpath trials:




  • //table[@aria-label="User Prompt Input"]


  • //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']


  • //table[@aria-label="User Prompt Input"]/@title


  • //tr//table[@aria-label="User Prompt Input"]/@title











share|improve this question















I am trying to click an image button, but i am getting org.openqa.selenium.NoSuchElementException. I even Checked if the element is present in any iframe by iterating through the frames. It is not present in any of the frames. Am i missing something?. Can someone please help me out with this.



Below is the code i am trying:



WebDriverWait wait2 = new WebDriverWait(driver,30);  
WebElement image = wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']")));
actions.click(image).build().perform();


Exception i am getting:



Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 45 seconds waiting for visibility of element located by By.xpath: //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'W1856237', ip: '192.168.43.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at com.ExpTestcases.TestOne.main(TestOne.java:105)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']"}
(Session info: chrome=70.0.3538.77)


And this is the html code for the image button:



<table role="button" aria-label="User Prompt Input" aria-pressed="false" title="User Prompt Input" style="display: block; cursor: pointer;" false"="" margin:0px"="" id="vertBar_leftPaneW_icon_3" class="" cellspacing="0" cellpadding="0" border="0" aria-labelledby="ariaLabelledBy_vertBar_leftPaneW_icon_3" tabindex="0">
<tbody>
<tr valign="middle">
<td id="iconleft_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
<td id="iconmid_vertBar_leftPaneW_icon_3" align="center" style="height:35px;" class="">
<div style="overflow:hidden;height:31px;" valign="middle">
<div id="IconImg_vertBar_leftPaneW_icon_3" class="imo" style="width:31px;height:31px;background-image:url('images/main/vertbar_icons.png');background-position:-1px -127px;margin-top:2px;cursor:pointer"></div>
</div>
</td>
<td id="iconright_vertBar_leftPaneW_icon_3" class="">
<div style="width:2px;height:35px"></div>
</td>
</tr>
</tbody>
</table>


Xpath trials:




  • //table[@aria-label="User Prompt Input"]


  • //tr//table[@title='User Prompt Input']//div[@id='IconImg_vertBar_leftPaneW_icon_3']


  • //table[@aria-label="User Prompt Input"]/@title


  • //tr//table[@aria-label="User Prompt Input"]/@title








java selenium selenium-webdriver xpath webdriverwait






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 11:14









DebanjanB

35k73270




35k73270










asked Nov 10 at 17:08









Ayisha

11




11












  • if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
    – Fabrice Zaks
    Nov 10 at 21:24




















  • if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
    – Fabrice Zaks
    Nov 10 at 21:24


















if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
– Fabrice Zaks
Nov 10 at 21:24






if running it only in selenium ide (and not web driver) is ok, you can use kantu's visual xclick (image of button) command and avoid debugging the xpath.
– Fabrice Zaks
Nov 10 at 21:24














1 Answer
1






active

oldest

votes

















up vote
0
down vote













As you are trying to invoke click() on the element so instead of using visibilityOfElementLocated() method you need to use elementToBeClickable() method and can use either of the following solutions:





  • cssSelector:



    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("table[id^='vertBar_leftPaneW_icon_'][aria-label='User Prompt Input'] div.imo[id^='IconImg_vertBar_leftPaneW_icon_'][style*='vertbar_icons']"))).click();



  • xpath:



    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[starts-with(@id,'vertBar_leftPaneW_icon_') and @aria-label='User Prompt Input']//div[@class='imo' and starts-with(@id,'IconImg_vertBar_leftPaneW_icon_')][contains(@style,'vertbar_icons')]"))).click();







share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241366%2funable-to-click-image-button%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    As you are trying to invoke click() on the element so instead of using visibilityOfElementLocated() method you need to use elementToBeClickable() method and can use either of the following solutions:





    • cssSelector:



      new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("table[id^='vertBar_leftPaneW_icon_'][aria-label='User Prompt Input'] div.imo[id^='IconImg_vertBar_leftPaneW_icon_'][style*='vertbar_icons']"))).click();



    • xpath:



      new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[starts-with(@id,'vertBar_leftPaneW_icon_') and @aria-label='User Prompt Input']//div[@class='imo' and starts-with(@id,'IconImg_vertBar_leftPaneW_icon_')][contains(@style,'vertbar_icons')]"))).click();







    share|improve this answer

























      up vote
      0
      down vote













      As you are trying to invoke click() on the element so instead of using visibilityOfElementLocated() method you need to use elementToBeClickable() method and can use either of the following solutions:





      • cssSelector:



        new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("table[id^='vertBar_leftPaneW_icon_'][aria-label='User Prompt Input'] div.imo[id^='IconImg_vertBar_leftPaneW_icon_'][style*='vertbar_icons']"))).click();



      • xpath:



        new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[starts-with(@id,'vertBar_leftPaneW_icon_') and @aria-label='User Prompt Input']//div[@class='imo' and starts-with(@id,'IconImg_vertBar_leftPaneW_icon_')][contains(@style,'vertbar_icons')]"))).click();







      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        As you are trying to invoke click() on the element so instead of using visibilityOfElementLocated() method you need to use elementToBeClickable() method and can use either of the following solutions:





        • cssSelector:



          new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("table[id^='vertBar_leftPaneW_icon_'][aria-label='User Prompt Input'] div.imo[id^='IconImg_vertBar_leftPaneW_icon_'][style*='vertbar_icons']"))).click();



        • xpath:



          new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[starts-with(@id,'vertBar_leftPaneW_icon_') and @aria-label='User Prompt Input']//div[@class='imo' and starts-with(@id,'IconImg_vertBar_leftPaneW_icon_')][contains(@style,'vertbar_icons')]"))).click();







        share|improve this answer












        As you are trying to invoke click() on the element so instead of using visibilityOfElementLocated() method you need to use elementToBeClickable() method and can use either of the following solutions:





        • cssSelector:



          new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("table[id^='vertBar_leftPaneW_icon_'][aria-label='User Prompt Input'] div.imo[id^='IconImg_vertBar_leftPaneW_icon_'][style*='vertbar_icons']"))).click();



        • xpath:



          new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[starts-with(@id,'vertBar_leftPaneW_icon_') and @aria-label='User Prompt Input']//div[@class='imo' and starts-with(@id,'IconImg_vertBar_leftPaneW_icon_')][contains(@style,'vertbar_icons')]"))).click();








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 11:32









        DebanjanB

        35k73270




        35k73270






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241366%2funable-to-click-image-button%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues