Selenium 常用代码
setSpeed 500
打开页
open /waitForPageToLoad
waitForElementPresent //DIV[@id='btnDirectLr']waitForElementPresent //DIV[text()='库存报表']verifyElementPresent css=div#msg-div:contains("审核成功")waitForElementPresent //DIV[@id='btnNew']waitForElementPresent //div[contains(@class, 'x-mask-msg') and contains(@style, 'display: none')]waitForElementNotPresent //DIV[@id='winForm' and contains(@style, 'visibility: hidden')]
click //DIV[text()='库存报表']click id=btnNewclick //DIV[@id='btnNew']/em/buttonclick //label[text()='仓库:']/following-sibling::div/div/divclick css='li.x-boundlist-item'
selectFrame content-iframewaitForFrameToLoadselectFrame relative=up
storeText //div[@id='grdMain']/div[2]/div/table/tbody/tr[2]/td[2]/div namestore 2 ckQty storeEval storedVars['oldQty']-storedVars['ckQty'] newQtyecho ${name}
verifyText //div[@id='grdMain']/div[2]/div/table/tbody/tr[2]/td[2]/div ${name}verifyText "css=div#grdMain td.x-grid-cell:nth-child(6) div" ${name}
type //input[@name='item[product_id]'] ${name}keyUp //input[@name='item[product_id]'] wwaitForElementPresent //div[contains(@class, 'x-mask-msg') and contains(@style, 'display: none')]waitForElementNotPresent //DIV[@id='blProducts' and contains(@class, 'display: none')]click //DIV[@id='blProducts']/div/ul/li[1]/aclick //DIV[@id='btnWinLiSave']/em/buttonclick //DIV[@id='btnWinSave']/em/buttonwaitForElementPresent //div[contains(@class, 'x-mask-msg') and contains(@style, 'display: none')]
mouseDown //div[@id='grdMain']/div[2]/div/table/tbody/tr[2]/tdclick //DIV[@id='btnAudited']/em/buttonclick //div[contains(@class, 'x-window x-message-box')]/div[3]/div/div[2]/em/buttonwaitForElementPresent //div[contains(@class, 'x-mask-msg') and contains(@style, 'display: none')]
runScript msg = '<div id="selenium-msg" style="background-color: orange;border-radius: 10px;font-size: 20px;left: 500px;line-height: 50px;position: absolute; text-align: center;top: 5px;width: 600px;z-index: 10000;"></div>'; Ext.DomHelper.insertFirst(Ext.getBody(), msg, true); runScript Ext.get('selenium-msg').dom.innerHTML = '测试物料出库库存变化'; runScript Ext.get('selenium-msg').dom.innerHTML = '得到测试数据'; runScript Ext.get('selenium-msg').dom.innerHTML = '测试完成';
waitForCondition !selenium.browserbot.getCurrentWindow().Ext.getCmp('treMain').getStore().loading 2000
click css=div#treMain .x-grid-row .x-grid-cell-inner:contains('库存报表')
waitForCondition selenium.browserbot.getCurrentWindow().Ext.MessageBox.isHidden() 1000
storeEval selenium.browserbot.getCurrentWindow().Page.grid.getStore().data.items[0].data product storeEval storedVars['product'].product_code name
waitForCondition selenium.browserbot.getCurrentWindow().Page.win.isVisible() 1000
runScript Page.frm.getForm().findField("item[warehouse_id]").expand() waitForCondition selenium.browserbot.getCurrentWindow().Ext.getCmp('frmMain').getForm().findField("item[warehouse_id]").isExpanded 1000 runScript Page.frm.getForm().findField("item[warehouse_id]").select(1) runScript Page.frm.getForm().findField("item[warehouse_id]").collapse()
type //input[@name='item[product_id]'] ${name} keyUp //input[@name='item[product_id]'] w waitForCondition selenium.browserbot.getCurrentWindow().Ext.MessageBox.isHidden() 1000 waitForCondition selenium.browserbot.getCurrentWindow().Ext.getCmp('frmLi').getForm().findField("item[product_id]").isExpanded 1000 click dom=selenium.browserbot.getCurrentWindow().Ext.getCmp('frmLi').getForm().findField("item[product_id]").getPicker().getNodes()[0] runScript Ext.getCmp('frmLi').getForm().findField("item[product_id]").collapse()
waitForCondition !selenium.browserbot.getCurrentWindow().Page.grid.getStore().loading 2000
storeEval selenium.browserbot.getCurrentWindow().Page.grid.getStore().data.items[0].data.code ckBillCode echo ckBillCode: ${ckBillCode}
click css=div#btnAudited em button click dom=selenium.browserbot.getCurrentWindow().Ext.MessageBox.msgButtons.yes.btnEl.dom verifyElementPresent css=div#msg-div:contains("审核成功")
verifyText css=div#grdMain td.x-grid-cell:nth-child(6) div ${newQty}.0