| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| LogItemPane | 32 | 6 | 0% | 4 | 2 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.extension.test.po; | |
| 21 | ||
| 22 | import org.openqa.selenium.By; | |
| 23 | import org.openqa.selenium.WebElement; | |
| 24 | import org.xwiki.test.ui.po.BaseElement; | |
| 25 | ||
| 26 | /** | |
| 27 | * Displays a log item. | |
| 28 | * | |
| 29 | * @version $Id: 4875c6bbf29426e825ae7f85aced99cba3187010 $ | |
| 30 | * @since 4.2M1 | |
| 31 | */ | |
| 32 | public class LogItemPane extends BaseElement | |
| 33 | { | |
| 34 | /** | |
| 35 | * The log item container. | |
| 36 | */ | |
| 37 | private final WebElement container; | |
| 38 | ||
| 39 | /** | |
| 40 | * Creates a new instance. | |
| 41 | * | |
| 42 | * @param container the log item container | |
| 43 | */ | |
| 44 | 113 | public LogItemPane(WebElement container) |
| 45 | { | |
| 46 | 113 | this.container = container; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @return the log item level (info, error, loading) | |
| 51 | */ | |
| 52 | 14 | public String getLevel() |
| 53 | { | |
| 54 | 14 | String[] classNames = container.getAttribute("class").split("\\s+"); |
| 55 | 14 | if (classNames.length < 2) { |
| 56 | 0 | return null; |
| 57 | } | |
| 58 | 14 | return classNames[classNames.length - 1].substring("log-item-".length()); |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * @return the log item message | |
| 63 | */ | |
| 64 | 14 | public String getMessage() |
| 65 | { | |
| 66 | 14 | return getDriver().findElementWithoutWaiting(container, By.tagName("DIV")).getText(); |
| 67 | } | |
| 68 | } |