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
java selenium selenium-webdriver xpath webdriverwait
add a comment |
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
java selenium selenium-webdriver xpath webdriverwait
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
add a comment |
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
java selenium selenium-webdriver xpath webdriverwait
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
java selenium selenium-webdriver xpath webdriverwait
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
add a comment |
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
add a comment |
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();
add a comment |
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();
add a comment |
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();
add a comment |
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();
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();
answered Nov 12 at 11:32
DebanjanB
35k73270
35k73270
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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