问题
I cant click on a Sencha 2 generated button as it isnt a input field. It builds up the button with divs and spans.
Found this link which describes how to click the buttons with a Selenium test http://mobilewebqa.blogspot.com/
Problem: How to click on a Sencha Touch button? The built in Selenium click, click_at, etc methods would not work.
Solution: Fake out a Sencha Touch tap event by using the following steps:
focus
mouse_down
mouse_up
But how do I invoke this events from Selenium?
Any other good advice how to test the UI is received with thanks. I saw someone mentioned Siesta, anyone used that?
http://www.bryntum.com/products/siesta/
回答1:
You can execute Javascript via Selenium. So you're able to use Ext.ComponentQuery.
((JavascriptExecutor) driver).executeScript("var button =
Ext.ComponentQuery.query('mypanel button')[0];
button.fireEvent('tap',button)");
This is not pretty but works.
回答2:
This is the step I use to simulate a tap on a button, but we're using Capybara, RSpec and Selenium :
page.find("span", :text => Regexp.new(THE_BUTTON_LABEL)).click
Hope you can make something out of it...
回答3:
You must find some way of directing Selenium to the button in Question.
Using a regular expression would work, but I believe it would be best to add attributes to the button as it makes it more obvious what is going on.
With the browser addon you can press record, then go back and choose from a dropdown of the criteria that Selenium selects by.
来源:https://stackoverflow.com/questions/11820363/using-selenium-to-test-sencha-2-app