开发者

How to click with jQuery in ZK

开发者 https://www.devze.com 2023-02-19 12:46 出处:网络
I have to use Selenium to test a website and I have to click on the button. But because it is ZK, I am using jQuery to do all actions, but the problem is that I can\'t click on the button.

I have to use Selenium to test a website and I have to click on the button. But because it is ZK, I am using jQuery to do all actions, but the problem is that I can't click on the button. Also I need to check a checkbox, but nothing is working with jQuery. Maybe you have any ideas how to click with jQuery in ZK and h开发者_如何学编程ow to check a checkbox?

For example something like:

jq('.z-button-os:eq(0)').click()

is not working.

Thank you!


I already got some pieces that works fine in my case:

To check last check-box:

jq('input[type=checkbox]:visible:last')[0].click()

Click last button:

jq('button').filter(':visible').filter(':last')[0].click()


should be something like:

jq('.z-button-os:eq(0)').click(function(){ //observe button click event
  jq('#checkbox-id').attr('checked',true); //check the checkbox
  return false; //prevent <a> tag jumping around
});

the jquery pseudo selector explanation:

in your first example you have :eq(0) this means that you want watch to the very first element in a given list; and you can use for this also a selector like :first


in your other example you have input[type=checkbox]:visible:last this means that you want to watch all the checkbox but keep only the last visible one, so it assume that you have also some hidden checkbox too. well this code can be easily rewrited as: $(':checkbox:visible:last').click()


then you have jq('button').filter(':visible').filter(':last')[0].click() that in practice mean exactly the same of above with the exeption that you are watching a button instead of a checkbox and can be rewrited as follow: $('button:visible:last').click()


  • DEMO: http://jsbin.com/ijile5
0

精彩评论

暂无评论...
验证码 换一张
取 消