montagejs / screening

50 stars 16 forks source link

assertContains != assertEqual #256

Closed irinamok closed 12 years ago

irinamok commented 12 years ago

The following code should pass, instead it fails because assertContains apparently works as assertEqual:


var agent = new Agent();

agent.gotoUrl("/screening/node_modules/montage/examples/sink/index.html");
agent.setWindowSize(807, 829);

var buttonComponent = agent.element("//*[@id='sidebar-list']/UL[1]/LI[1]/A/H4");
var toggleComponent = agent.element("//*[@id='sidebar-list']/UL[1]/LI[2]/A/H4");
var anchorComponent = agent.element("//*[@id='sidebar-list']/UL[1]/LI[3]/A/H4");

var dyntextComponent = agent.element("//*[@id='sidebar-list']/UL[2]/LI/A/H4");

var textfieldComponent = agent.element("//*[@id='sidebar-list']/UL[3]/LI[1]/A/H4");
var autocompleteComponent = agent.element("//*[@id='sidebar-list']/UL[3]/LI[2]/A/H4");
var textareaComponent = agent.element("//*[@id='sidebar-list']/UL[3]/LI[3]/A/H4");

var rangeComponent = agent.element("//*[@id='sidebar-list']/UL[4]/LI[1]/A/H4"); 
var rangepolyfillComponent = agent.element("//*[@id='sidebar-list']/UL[4]/LI[2]/A/H4");
var msliderComponent = agent.element("//*[@id='sidebar-list']/UL[4]/LI[3]/A/H4");
var numberComponent = agent.element("//*[@id='sidebar-list']/UL[4]/LI[4]/A/H4");

var selectComponent = agent.element("//*[@id='sidebar-list']/UL[5]/LI[1]/A/H4");
var checkboxComponent = agent.element("//*[@id='sidebar-list']/UL[5]/LI[2]/A/H4");
var rbuttonComponent = agent.element("//*[@id='sidebar-list']/UL[5]/LI[3]/A/H4");

var listComponent = agent.element("//*[@id='sidebar-list']/UL[6]/LI[1]/A/H4");
var repetitionComponent = agent.element("//*[@id='sidebar-list']/UL[6]/LI[2]/A/H4");

var overlaysComponent = agent.element("//*[@id='sidebar-list']/UL[7]/LI[1]/A/H4");
var substitutionComponent = agent.element("//*[@id='sidebar-list']/UL[7]/LI[2]/A/H4");
var tabComponent = agent.element("//*[@id='sidebar-list']/UL[7]/LI[3]/A/H4");
var scrollerComponent = agent.element("//*[@id='sidebar-list']/UL[7]/LI[4]/A/H4");

var translatecompComponent = agent.element("//*[@id='sidebar-list']/UL[8]/LI[1]/A/H4");
var converterComponent = agent.element("//*[@id='sidebar-list']/UL[8]/LI[2]/A/H4");
var progressComponent = agent.element("//*[@id='sidebar-list']/UL[8]/LI[3]/A/H4");
var imgComponent = agent.element("//*[@id='sidebar-list']/UL[8]/LI[4]/A/H4");

assertEqual("Please select a Component to view",agent.element("/HTML/BODY/DIV/DIV/DIV[2]/DIV[2]/H5").getText());

//Test Button
buttonComponent.click();
agent.wait(2000);
assertEqual("Button",agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[1]/DIV/H3").getText());

var clickMe = agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[2]/DIV/BUTTON");
var submit = agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[3]/DIV/INPUT");
var copy = agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[4]/DIV/DIV/BUTTON[1]");
var cut = agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[4]/DIV/DIV/BUTTON[2]");
var paste = agent.element("/HTML/BODY/DIV[1]/DIV/DIV[2]/DIV[2]/DIV/DIV[4]/DIV/DIV/BUTTON[3]");

var logger = agent.element("/HTML/BODY/DIV/DIV/DIV[2]/DIV[2]/DIV/SECTION[7]/DIV/DIV");

assertEqual ("logger", agent.element("/HTML/BODY/DIV/DIV/DIV[2]/DIV[2]/DIV/SECTION[7]/DIV").getAttribute("class"));
clickMe.click();
assertEqual ("logger logger-hilight", agent.element("/HTML/BODY/DIV/DIV/DIV[2]/DIV[2]/DIV/SECTION[7]/DIV").getAttribute("class"));
assertContains ("Button - button1 - clicked",logger.getText());
zacharyc commented 12 years ago

Your test is wrong. The last line should be reversed:

assertContains (logger.getText(), "Button - button1 - clicked");

The parameters for this function are assertContains(collection, value, msg); meaning the collection needs to be the first parameter. I changed this per your last request with assertContains