How can I check if a non-input text element is clickable in Selenium? (Java)How can I concatenate two arrays in Java?How to check if a String is numeric in JavaHow do I check if a file exists in Java?How to verify ANY text is present with selenium IDESelenium Check for text to changeHow to assert text is not present for a specific element in python/selenium?How to assert that element exists on the page using Node.js + Mocha + Selenium?How to check if element is clickable in Selenium WebDriver using JavaSelenium Java : wait until clickableNot able to find element by partial link text using Java and Selenium

Why would future John risk sending back a T-800 to save his younger self?

Does Disney no longer produce hand-drawn cartoon films?

What speaks against investing in precious metals?

Is a lack of character descriptions a problem?

1980s live-action movie where individually-coloured nations on clouds fight

Certain search in list

How to create a pyramidal panel for a door?

Which physicist is this quote attributed to?

How to hide an urban landmark?

A king was born in a year that was a perfect square, lived a perfect square number of years, and also died in a year that was a perfect square

Mathematically, why does mass matrix / load vector lumping work?

What makes Ada the language of choice for the ISS's safety-critical systems?

Proof that 1-P(B|C)=P(~B|C). Is everything correct?

Paying more mana for a Flashed creature

Soft question: Examples where lack of mathematical rigour cause security breaches?

Why can't I use =default for default ctors with a member initializer list

How to draw a Technology Radar?

Can Rydberg constant be in joules?

Determining fair price for profitable mobile app business

How do governments keep track of their issued currency?

Can U.S. Tax Forms Be Legally HTMLified?

Why didn't Voldemort recognize that Dumbledore was affected by his curse?

Need feedback - Can the composition/colors of this design be fixed if something is lacking or is not a better fit?

The use of かります in a sentence



How can I check if a non-input text element is clickable in Selenium? (Java)


How can I concatenate two arrays in Java?How to check if a String is numeric in JavaHow do I check if a file exists in Java?How to verify ANY text is present with selenium IDESelenium Check for text to changeHow to assert text is not present for a specific element in python/selenium?How to assert that element exists on the page using Node.js + Mocha + Selenium?How to check if element is clickable in Selenium WebDriver using JavaSelenium Java : wait until clickableNot able to find element by partial link text using Java and Selenium






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I'm trying to check the clickability of a non-input text element (which can only be viewed but not edited). I have a test that where I want to assert that the view only text element (Ex: First Name) displayed on page can not be clicked.



I have tried using the isEnabled() method to check if the view only text element is enabled or not but the assertion is not happening correctly.



This is Bobcat Selenium code



Step definition code:



@Then("^I should verify that the First Name is not clickable$")
public void iShouldVerifyThatTheFirstNameIsNotClickable()
assertEquals("Error: First Name is clickable", true,
fullName.verifyClick());



Page Object code:



public boolean verifyClick() 
if (firstName.isEnabled())
return true;

else
return false;




Expected result: Since firstName is a view only element, the result of the verifyClick() method should be false so my @Then("^I should verify that the First Name is not clickable$") result should fail since the assertion is failing.



Actual result: @Then("^I should verify that the First Name is not clickable$") result is success.










share|improve this question



















  • 1





    The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

    – JeffC
    Mar 24 at 21:08











  • BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

    – JeffC
    Mar 24 at 21:08











  • The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

    – Ardesco
    Apr 8 at 9:51

















2















I'm trying to check the clickability of a non-input text element (which can only be viewed but not edited). I have a test that where I want to assert that the view only text element (Ex: First Name) displayed on page can not be clicked.



I have tried using the isEnabled() method to check if the view only text element is enabled or not but the assertion is not happening correctly.



This is Bobcat Selenium code



Step definition code:



@Then("^I should verify that the First Name is not clickable$")
public void iShouldVerifyThatTheFirstNameIsNotClickable()
assertEquals("Error: First Name is clickable", true,
fullName.verifyClick());



Page Object code:



public boolean verifyClick() 
if (firstName.isEnabled())
return true;

else
return false;




Expected result: Since firstName is a view only element, the result of the verifyClick() method should be false so my @Then("^I should verify that the First Name is not clickable$") result should fail since the assertion is failing.



Actual result: @Then("^I should verify that the First Name is not clickable$") result is success.










share|improve this question



















  • 1





    The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

    – JeffC
    Mar 24 at 21:08











  • BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

    – JeffC
    Mar 24 at 21:08











  • The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

    – Ardesco
    Apr 8 at 9:51













2












2








2


0






I'm trying to check the clickability of a non-input text element (which can only be viewed but not edited). I have a test that where I want to assert that the view only text element (Ex: First Name) displayed on page can not be clicked.



I have tried using the isEnabled() method to check if the view only text element is enabled or not but the assertion is not happening correctly.



This is Bobcat Selenium code



Step definition code:



@Then("^I should verify that the First Name is not clickable$")
public void iShouldVerifyThatTheFirstNameIsNotClickable()
assertEquals("Error: First Name is clickable", true,
fullName.verifyClick());



Page Object code:



public boolean verifyClick() 
if (firstName.isEnabled())
return true;

else
return false;




Expected result: Since firstName is a view only element, the result of the verifyClick() method should be false so my @Then("^I should verify that the First Name is not clickable$") result should fail since the assertion is failing.



Actual result: @Then("^I should verify that the First Name is not clickable$") result is success.










share|improve this question
















I'm trying to check the clickability of a non-input text element (which can only be viewed but not edited). I have a test that where I want to assert that the view only text element (Ex: First Name) displayed on page can not be clicked.



I have tried using the isEnabled() method to check if the view only text element is enabled or not but the assertion is not happening correctly.



This is Bobcat Selenium code



Step definition code:



@Then("^I should verify that the First Name is not clickable$")
public void iShouldVerifyThatTheFirstNameIsNotClickable()
assertEquals("Error: First Name is clickable", true,
fullName.verifyClick());



Page Object code:



public boolean verifyClick() 
if (firstName.isEnabled())
return true;

else
return false;




Expected result: Since firstName is a view only element, the result of the verifyClick() method should be false so my @Then("^I should verify that the First Name is not clickable$") result should fail since the assertion is failing.



Actual result: @Then("^I should verify that the First Name is not clickable$") result is success.







java selenium webdriver webdriverwait isenabled






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 8:23









DebanjanB

51.3k145299




51.3k145299










asked Mar 24 at 18:02









PariPari

134




134







  • 1





    The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

    – JeffC
    Mar 24 at 21:08











  • BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

    – JeffC
    Mar 24 at 21:08











  • The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

    – Ardesco
    Apr 8 at 9:51












  • 1





    The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

    – JeffC
    Mar 24 at 21:08











  • BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

    – JeffC
    Mar 24 at 21:08











  • The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

    – Ardesco
    Apr 8 at 9:51







1




1





The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

– JeffC
Mar 24 at 21:08





The problem that you are running into is that the element can be clicked... it just won't do anything. Just as a user can click an element that is disabled, but it does nothing. Instead I would focus on the classes of the element when it is disabled. I'm assuming that certain classes exist on the element when it is disabled that give it that disabled look. Check to see if those classes exist on the element and use that to determine disabled or not.

– JeffC
Mar 24 at 21:08













BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

– JeffC
Mar 24 at 21:08





BTW... your verifyClick() method can be reduced to return firstName.isEnabled().

– JeffC
Mar 24 at 21:08













The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

– Ardesco
Apr 8 at 9:51





The real question here, is what is your definition of clickable? Are you checking it's not an anchor, or a button, or a specific HTML tag. Or are you really trying to check that doesn't have a JavaScript listener bound to it? Maybe you want to check it's not wrapped, or referenced, by a label tag?

– Ardesco
Apr 8 at 9:51












1 Answer
1






active

oldest

votes


















1














There is a part of the selenium Java bindings that could be useful to you here. In ExpectedConditions you'll find a function called elementToBeClickable(). This returns a boolean that's false whenever the element is not clickable for any reason, and true when it can receive a click. So you just want to wait and see if that function returns true. Selenium handles that as well with the WebDriverWait class.



So you'll need to import both of those, and then you can do something like this:



//setting the timeout for our wait to be 20 seconds (you can use whatever you want)
WebDriverWait myWaitVar = new WebDriverWait(driver,20);
try
WebElement myElement = myWaitVar.until(ExpectedConditions.elementToBeClickable(firstName)));
//assert test failed!

catch(timeoutException timeout)
//whatever you want to do when the element is not clickable






share|improve this answer

























  • While this will work, you will wait for 20s to find out that it's not clickable.

    – JeffC
    Mar 24 at 21:06











  • Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

    – C. Peck
    Mar 24 at 21:09






  • 1





    Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

    – Sers
    Mar 24 at 21:21












  • @Sers could you provide a little more detail? Why does that not achieve the user's goal?

    – C. Peck
    Mar 24 at 21:27






  • 1





    @C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

    – Sers
    Mar 24 at 21:37











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',
autoActivateHeartbeat: false,
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%2f55326839%2fhow-can-i-check-if-a-non-input-text-element-is-clickable-in-selenium-java%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









1














There is a part of the selenium Java bindings that could be useful to you here. In ExpectedConditions you'll find a function called elementToBeClickable(). This returns a boolean that's false whenever the element is not clickable for any reason, and true when it can receive a click. So you just want to wait and see if that function returns true. Selenium handles that as well with the WebDriverWait class.



So you'll need to import both of those, and then you can do something like this:



//setting the timeout for our wait to be 20 seconds (you can use whatever you want)
WebDriverWait myWaitVar = new WebDriverWait(driver,20);
try
WebElement myElement = myWaitVar.until(ExpectedConditions.elementToBeClickable(firstName)));
//assert test failed!

catch(timeoutException timeout)
//whatever you want to do when the element is not clickable






share|improve this answer

























  • While this will work, you will wait for 20s to find out that it's not clickable.

    – JeffC
    Mar 24 at 21:06











  • Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

    – C. Peck
    Mar 24 at 21:09






  • 1





    Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

    – Sers
    Mar 24 at 21:21












  • @Sers could you provide a little more detail? Why does that not achieve the user's goal?

    – C. Peck
    Mar 24 at 21:27






  • 1





    @C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

    – Sers
    Mar 24 at 21:37















1














There is a part of the selenium Java bindings that could be useful to you here. In ExpectedConditions you'll find a function called elementToBeClickable(). This returns a boolean that's false whenever the element is not clickable for any reason, and true when it can receive a click. So you just want to wait and see if that function returns true. Selenium handles that as well with the WebDriverWait class.



So you'll need to import both of those, and then you can do something like this:



//setting the timeout for our wait to be 20 seconds (you can use whatever you want)
WebDriverWait myWaitVar = new WebDriverWait(driver,20);
try
WebElement myElement = myWaitVar.until(ExpectedConditions.elementToBeClickable(firstName)));
//assert test failed!

catch(timeoutException timeout)
//whatever you want to do when the element is not clickable






share|improve this answer

























  • While this will work, you will wait for 20s to find out that it's not clickable.

    – JeffC
    Mar 24 at 21:06











  • Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

    – C. Peck
    Mar 24 at 21:09






  • 1





    Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

    – Sers
    Mar 24 at 21:21












  • @Sers could you provide a little more detail? Why does that not achieve the user's goal?

    – C. Peck
    Mar 24 at 21:27






  • 1





    @C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

    – Sers
    Mar 24 at 21:37













1












1








1







There is a part of the selenium Java bindings that could be useful to you here. In ExpectedConditions you'll find a function called elementToBeClickable(). This returns a boolean that's false whenever the element is not clickable for any reason, and true when it can receive a click. So you just want to wait and see if that function returns true. Selenium handles that as well with the WebDriverWait class.



So you'll need to import both of those, and then you can do something like this:



//setting the timeout for our wait to be 20 seconds (you can use whatever you want)
WebDriverWait myWaitVar = new WebDriverWait(driver,20);
try
WebElement myElement = myWaitVar.until(ExpectedConditions.elementToBeClickable(firstName)));
//assert test failed!

catch(timeoutException timeout)
//whatever you want to do when the element is not clickable






share|improve this answer















There is a part of the selenium Java bindings that could be useful to you here. In ExpectedConditions you'll find a function called elementToBeClickable(). This returns a boolean that's false whenever the element is not clickable for any reason, and true when it can receive a click. So you just want to wait and see if that function returns true. Selenium handles that as well with the WebDriverWait class.



So you'll need to import both of those, and then you can do something like this:



//setting the timeout for our wait to be 20 seconds (you can use whatever you want)
WebDriverWait myWaitVar = new WebDriverWait(driver,20);
try
WebElement myElement = myWaitVar.until(ExpectedConditions.elementToBeClickable(firstName)));
//assert test failed!

catch(timeoutException timeout)
//whatever you want to do when the element is not clickable







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 21:08

























answered Mar 24 at 18:25









C. PeckC. Peck

960324




960324












  • While this will work, you will wait for 20s to find out that it's not clickable.

    – JeffC
    Mar 24 at 21:06











  • Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

    – C. Peck
    Mar 24 at 21:09






  • 1





    Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

    – Sers
    Mar 24 at 21:21












  • @Sers could you provide a little more detail? Why does that not achieve the user's goal?

    – C. Peck
    Mar 24 at 21:27






  • 1





    @C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

    – Sers
    Mar 24 at 21:37

















  • While this will work, you will wait for 20s to find out that it's not clickable.

    – JeffC
    Mar 24 at 21:06











  • Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

    – C. Peck
    Mar 24 at 21:09






  • 1





    Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

    – Sers
    Mar 24 at 21:21












  • @Sers could you provide a little more detail? Why does that not achieve the user's goal?

    – C. Peck
    Mar 24 at 21:27






  • 1





    @C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

    – Sers
    Mar 24 at 21:37
















While this will work, you will wait for 20s to find out that it's not clickable.

– JeffC
Mar 24 at 21:06





While this will work, you will wait for 20s to find out that it's not clickable.

– JeffC
Mar 24 at 21:06













Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

– C. Peck
Mar 24 at 21:09





Yes, maybe something like 5s would be more reasonable. The user can pass in whatever parameter they like.

– C. Peck
Mar 24 at 21:09




1




1





Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

– Sers
Mar 24 at 21:21






Problem is elementToBeClickable checks if element isDisplayed and isEnabled, and will not solve the problem.

– Sers
Mar 24 at 21:21














@Sers could you provide a little more detail? Why does that not achieve the user's goal?

– C. Peck
Mar 24 at 21:27





@Sers could you provide a little more detail? Why does that not achieve the user's goal?

– C. Peck
Mar 24 at 21:27




1




1





@C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

– Sers
Mar 24 at 21:37





@C.Peck for any html element not support disabled attribute (support elements), isEnabled return true.

– Sers
Mar 24 at 21:37



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326839%2fhow-can-i-check-if-a-non-input-text-element-is-clickable-in-selenium-java%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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해