|
| 1 | +/* |
| 2 | + * Copyright 2002-2007 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.suren.autotest.web.framework.util; |
| 18 | + |
| 19 | +import java.io.IOException; |
| 20 | + |
| 21 | +import org.dom4j.DocumentException; |
| 22 | +import org.junit.After; |
| 23 | +import org.junit.Before; |
| 24 | +import org.junit.Test; |
| 25 | +import org.suren.autotest.web.framework.page.HomePage; |
| 26 | +import org.suren.autotest.web.framework.page.LoginPage; |
| 27 | +import org.suren.autotest.web.framework.settings.SettingUtil; |
| 28 | +import org.xml.sax.SAXException; |
| 29 | + |
| 30 | +/** |
| 31 | + * 元素批量操作的工具类单元测试 |
| 32 | + * @author suren |
| 33 | + * @date 2017年5月14日 下午9:43:38 |
| 34 | + */ |
| 35 | +public class ElementUtilTest |
| 36 | +{ |
| 37 | + private SettingUtil util; |
| 38 | + |
| 39 | + /** |
| 40 | + * 加载元素定位信息,初始化数据源 |
| 41 | + * @throws IOException |
| 42 | + * @throws DocumentException |
| 43 | + * @throws SAXException |
| 44 | + */ |
| 45 | + @Before |
| 46 | + public void before() throws IOException, DocumentException, SAXException |
| 47 | + { |
| 48 | + util = new SettingUtil(); |
| 49 | + util.readFromClassPath("elements/xml/maimai_chrome.xml"); |
| 50 | + util.initData(); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * 释放资源 |
| 55 | + * @throws IOException |
| 56 | + */ |
| 57 | + @After |
| 58 | + public void after() throws IOException |
| 59 | + { |
| 60 | + util.close(); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void buttonClick() throws IOException, DocumentException, SAXException |
| 65 | + { |
| 66 | + HomePage homePage = util.getPage(HomePage.class); |
| 67 | + homePage.open(); |
| 68 | + ElementUtil.click(homePage.getToLoginBut()); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void textFillValue() |
| 73 | + { |
| 74 | + HomePage homePage = util.getPage(HomePage.class); |
| 75 | + homePage.open(); |
| 76 | + ElementUtil.click(homePage.getToLoginBut()); |
| 77 | + |
| 78 | + LoginPage loginPage = util.getPage(LoginPage.class); |
| 79 | + ElementUtil.fillValue(loginPage.getPhone(), loginPage.getPassword()); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void pageOperation() |
| 84 | + { |
| 85 | + HomePage homePage = util.getPage(HomePage.class); |
| 86 | + homePage.open(); |
| 87 | + ElementUtil.click(homePage); |
| 88 | + |
| 89 | + LoginPage loginPage = util.getPage(LoginPage.class); |
| 90 | + ElementUtil.fillValue(loginPage); |
| 91 | + ElementUtil.click(loginPage); |
| 92 | + } |
| 93 | +} |
0 commit comments