Changeset 1069 for trunk/autoquest-plugin-html/src/main/java/de/ugoe
- Timestamp:
- 02/14/13 15:20:07 (12 years ago)
- Location:
- trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html
- Files:
-
- 1 added
- 2 deleted
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java
r1064 r1069 15 15 package de.ugoe.cs.autoquest.plugin.html; 16 16 17 import java.io.File;18 import java.io.FileInputStream;19 import java.io.FileNotFoundException;20 import java.io.IOException;21 import java.io.InputStreamReader;22 import java.io.UnsupportedEncodingException;23 import java.util.Collection;24 import java.util.HashMap;25 import java.util.LinkedList;26 17 import java.util.List; 27 18 import java.util.Map; 28 29 import javax.xml.parsers.ParserConfigurationException; 30 import javax.xml.parsers.SAXParser; 31 import javax.xml.parsers.SAXParserFactory; 32 33 import org.xml.sax.Attributes; 34 import org.xml.sax.InputSource; 19 import java.util.regex.Matcher; 20 import java.util.regex.Pattern; 21 35 22 import org.xml.sax.SAXException; 36 import org.xml.sax.SAXParseException;37 import org.xml.sax.helpers.DefaultHandler;38 23 39 24 import de.ugoe.cs.autoquest.eventcore.Event; 40 25 import de.ugoe.cs.autoquest.eventcore.IEventType; 41 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIElementTree;42 26 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel; 43 27 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 44 28 import de.ugoe.cs.autoquest.plugin.html.eventcore.HTMLEventTypeFactory; 29 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLDocumentSpec; 45 30 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElement; 46 31 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElementSpec; 47 32 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLPageElementSpec; 48 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLPageSpec;49 33 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLServerSpec; 50 import de.ugoe.cs.util.console.Console;51 34 52 35 /** 53 36 * <p> 54 37 * This class provides the functionality to parse XML log files generated by the HTMLMonitor of 55 * autoquest. The result of parsing a file is a collection of event sequences.38 * AutoQUEST. The result of parsing a file is a collection of event sequences and a GUI model 56 39 * </p> 57 40 * 58 * @author Fabian Glaser 41 * @author Fabian Glaser, Patrick Harms 59 42 * @version 1.0 60 43 * 61 44 */ 62 public class HTMLLogParser extends DefaultHandler { 45 public class HTMLLogParser extends AbstractDefaultLogParser { 46 47 /** 48 * 49 */ 50 private Pattern htmlElementPattern = 51 Pattern.compile("(\\w+)(\\[(\\d+)\\]|\\(htmlId=([\\w-]+)\\))"); 52 53 /* (non-Javadoc) 54 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleGUIElement(java.lang.String, java.util.Map) 55 */ 56 @Override 57 protected boolean handleGUIElement(String id, Map<String, String> parameters) 58 throws SAXException 59 { 60 HTMLGUIElementSpec specification = null; 61 62 String parentId = parameters.get("parent"); 63 IGUIElement parent = super.getGUIElementTree().find(parentId); 64 65 if (parameters.containsKey("host")) { 66 // this is a server specification 67 int port = 80; 68 String portStr = parameters.get(port); 69 70 if (portStr != null) { 71 port = Integer.parseInt(portStr); 72 } 73 74 specification = new HTMLServerSpec(parameters.get("host"), port); 75 } 76 else if (parameters.containsKey("path")) { 77 // this is a document specification 78 79 if (parent != null) { 80 if (!(parent.getSpecification() instanceof HTMLServerSpec)) { 81 throw new SAXException 82 ("invalid log: parent GUI element of a document is not of type server"); 83 } 84 85 specification = new HTMLDocumentSpec 86 ((HTMLServerSpec) parent.getSpecification(), parameters.get("path"), 87 parameters.get("query"), parameters.get("title")); 88 } 89 else if (parentId == null) { 90 throw new SAXException("invalid log: a document has no parent id"); 91 } 92 } 93 else if (parameters.containsKey("tagname")) { 94 String tagName = parameters.get("tagname"); 95 96 if (!tagNameMustBeConsidered(tagName)) { 97 return true; 98 } 99 100 if (parent != null) { 101 IGUIElement document = parent; 102 103 while ((document != null) && 104 (!(document.getSpecification() instanceof HTMLDocumentSpec))) 105 { 106 document = document.getParent(); 107 } 108 109 if (document == null) { 110 throw new SAXException 111 ("invalid log: parent hierarchy of a page element does not contain a " + 112 "document"); 113 } 114 115 int index = -1; 116 String indexStr = parameters.get("index"); 117 118 if ((indexStr != null) && (!"".equals(indexStr))) { 119 index = Integer.parseInt(indexStr); 120 } 121 122 specification = new HTMLPageElementSpec 123 ((HTMLDocumentSpec) document.getSpecification(), tagName, 124 parameters.get("htmlid"), index); 125 } 126 else if (parentId == null) { 127 throw new SAXException("invalid log: a page element has no parent id"); 128 } 129 } 130 else { 131 throw new SAXException("invalid log: unknown GUI element"); 132 } 133 134 if (specification != null) { 135 super.getGUIElementTree().add(id, parentId, specification); 136 return true; 137 } 138 else { 139 return false; 140 } 141 } 142 143 /* (non-Javadoc) 144 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent(java.lang.String, java.util.Map) 145 */ 146 @Override 147 protected boolean handleEvent(String type, Map<String, String> parameters) throws SAXException { 148 String targetId = parameters.get("target"); 149 150 if (targetId == null) { 151 String targetDocument = parameters.get("targetDocument"); 152 String targetDOMPath = parameters.get("targetDOMPath"); 153 154 if ((targetDocument == null) || (targetDOMPath == null)) { 155 throw new SAXException("event has no target defined"); 156 } 157 158 targetId = determineTargetId(targetDocument, targetDOMPath); 159 160 if (targetId == null) { 161 // the target id can not be determined yet 162 return false; 163 } 164 } 165 166 IGUIElement target = super.getGUIElementTree().find(targetId); 167 168 if (target == null) { 169 // event not processable yet 170 return false; 171 } 172 173 IEventType eventType = 174 HTMLEventTypeFactory.getInstance().getEventType(type, parameters, target); 175 176 Event event = new Event(eventType, target); 177 178 String timestampStr = parameters.get("timestamp"); 179 180 if (timestampStr != null) { 181 event.setTimestamp(Long.parseLong(timestampStr)); 182 } 183 184 ((HTMLGUIElement) event.getTarget()).markUsed(); 185 186 super.addToSequence(event); 187 188 return true; 189 } 190 63 191 /** 64 192 * <p> 65 * Constructor. Creates a new HTMLLogParser.193 * TODO: comment 66 194 * </p> 67 */ 68 public HTMLLogParser() { 69 sequences = new LinkedList<List<Event>>(); 195 * 196 * @param targetDocument 197 * @param targetDOMPath 198 * @return 199 */ 200 private String determineTargetId(String targetDocument, String targetDOMPath) 201 throws SAXException 202 { 203 IGUIElement document = super.getGUIElementTree().find(targetDocument); 204 205 if (document == null) { 206 return null; 207 } 208 209 if (!(document.getSpecification() instanceof HTMLDocumentSpec)) { 210 throw new SAXException("an id that should refer to an HTML document refers to" + 211 "something else"); 212 } 213 214 GUIModel model = super.getGUIElementTree().getGUIModel(); 215 IGUIElement child = document; 216 String[] pathElements = targetDOMPath.split("/"); 217 int pathIndex = 0; 218 219 HTMLPageElementSpec compareSpec; 220 String tagName; 221 int index; 222 String htmlId; 223 224 while ((pathIndex < pathElements.length) && (child != null)) { 225 if ((pathElements[pathIndex] != null) && (!"".equals(pathElements[pathIndex]))) { 226 Matcher matcher = htmlElementPattern.matcher(pathElements[pathIndex]); 227 if (!matcher.matches()) { 228 throw new SAXException 229 ("could not parse target DOM path element " + pathElements[pathIndex]); 230 } 231 232 tagName = matcher.group(1); 233 String indexStr = matcher.group(3); 234 htmlId = matcher.group(4); 235 236 index = -1; 237 if ((indexStr != null) && (!"".equals(indexStr))) { 238 index = Integer.parseInt(indexStr); 239 } 240 241 compareSpec = new HTMLPageElementSpec 242 ((HTMLDocumentSpec) document.getSpecification(), tagName, htmlId, index); 243 244 List<IGUIElement> children = model.getChildren(child); 245 child = null; 246 247 for (IGUIElement candidate : children) { 248 if (compareSpec.getSimilarity(candidate.getSpecification())) { 249 child = candidate; 250 break; 251 } 252 } 253 } 254 255 pathIndex++; 256 } 257 258 if (child != null) { 259 return super.getGUIElementTree().find(child); 260 } 261 else { 262 return null; 263 } 70 264 } 71 265 72 266 /** 73 267 * <p> 74 * Collection of event sequences that is contained in the parsed log file. 268 * checks if tags with the provided name must be handled in the GUI model. As an example, 269 * it is not necessary to handle "head" tags and anything included in them. 75 270 * </p> 76 */ 77 private Collection<List<Event>> sequences; 78 79 /** 80 * <p> 81 * Internal handle to the parsed GUI structure, stored in a GUIElementTree 82 * </p> 83 */ 84 private GUIElementTree<String> currentGUIElementTree; 85 86 /** 87 * <p> 88 * Path of the GUI element currently being parsed. 89 * </p> 90 */ 91 private String currentGUIElementPath; 92 93 /** 94 * <p> 95 * Path of the parent of the GUI element currently being parsed. 96 * </p> 97 */ 98 private String currentParentPath; 99 100 /** 101 * <p> 102 * Source of the GUI element currently being parsed. 103 * </p> 104 */ 105 private String currentEventSource; 106 107 /** 108 * <p> 109 * Timestamp of the event currently being parsed. 110 * </p> 111 */ 112 private Long currentEventTimestamp; 113 114 /** 115 * <p> 116 * Internal handle to the parameters of the event currently being parsed. 117 * </p> 118 */ 119 private Map<String, String> currentEventParameters; 120 121 /** 122 * <p> 123 * Internal handle to the parameters of the GUI element currently being parsed. 124 * </p> 125 */ 126 private Map<String, String> currentGUIElementParameters; 127 /** 128 * <p> 129 * Internal handle to the sequence currently being parsed. 130 * </p> 131 */ 132 private List<Event> currentSequence; 133 134 /** 135 * <p> 136 * Internal handle to type of the event currently being parsed. 137 * </p> 138 */ 139 private String currentEventType; 140 141 /** 142 * <p> 143 * Class of the GUI element currently being parsed. 144 * </p> 145 */ 146 private String currentGUIElementClass; 147 148 /** 149 * <p> 150 * Index of the GUI element currently being parsed. 151 * </p> 152 */ 153 private String currentGUIElementIndex; 154 155 /** 156 * <p> 157 * internal handle to the GUI element of the previous event to be potentially reused for the 158 * current 159 * </p> 160 */ 161 private IGUIElement lastGUIElement; 162 163 /** 164 * <p> 165 * internal handle to the server specification currently being used. 166 * </p> 167 */ 168 private HTMLServerSpec currentServerSpec; 169 170 /** 171 * <p> 172 * Parses a log file written by the HTMLMonitor and creates a collection of event sequences. 173 * </p> 174 * 175 * @param filename 176 * name and path of the log file 177 */ 178 public void parseFile(String filename) { 179 if (filename == null) { 180 throw new IllegalArgumentException("filename must not be null"); 181 } 182 183 parseFile(new File(filename)); 184 } 185 186 /** 187 * <p> 188 * Parses a log file written by the HTMLMonitor and creates a collection of event sequences. 189 * </p> 190 * 191 * @param file 192 * file to be parsed 193 */ 194 public void parseFile(File file) { 195 if (file == null) { 196 throw new IllegalArgumentException("file must not be null"); 197 } 198 SAXParserFactory spf = SAXParserFactory.newInstance(); 199 spf.setValidating(true); 200 SAXParser saxParser = null; 201 InputSource inputSource = null; 202 try { 203 saxParser = spf.newSAXParser(); 204 inputSource = 205 new InputSource(new InputStreamReader(new FileInputStream(file), "UTF-8")); 206 } 207 catch (UnsupportedEncodingException e) { 208 Console.printerr("Error parsing file " + file.getName()); 209 Console.logException(e); 210 return; 211 } 212 catch (ParserConfigurationException e) { 213 Console.printerr("Error parsing file " + file.getName()); 214 Console.logException(e); 215 return; 216 } 217 catch (SAXException e) { 218 Console.printerr("Error parsing file " + file.getName()); 219 Console.logException(e); 220 } 221 catch (FileNotFoundException e) { 222 Console.printerr("Error parsing file " + file.getName()); 223 Console.logException(e); 224 } 225 if (inputSource != null) { 226 inputSource.setSystemId("file://" + file.getAbsolutePath()); 227 try { 228 if (saxParser == null) { 229 throw new RuntimeException("SaxParser creation failed"); 230 } 231 saxParser.parse(inputSource, this); 232 } 233 catch (SAXParseException e) { 234 Console.printerrln("Failure parsing file in line " + e.getLineNumber() + 235 ", column " + e.getColumnNumber() + "."); 236 Console.logException(e); 237 } 238 catch (SAXException e) { 239 Console.printerr("Error parsing file " + file.getName()); 240 Console.logException(e); 241 return; 242 } 243 catch (IOException e) { 244 Console.printerr("Error parsing file " + file.getName()); 245 Console.logException(e); 246 return; 247 } 248 } 249 } 250 251 /* 252 * (non-Javadoc) 253 * 254 * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, 255 * java.lang.String, org.xml.sax.Attributes) 256 */ 257 @Override 258 public void startElement(String uri, String localName, String qName, Attributes atts) 259 throws SAXException 260 { 261 if (qName.equals("session")) { 262 currentSequence = new LinkedList<Event>(); 263 if (currentGUIElementTree == null) 264 currentGUIElementTree = new GUIElementTree<String>(); 265 } 266 else if (qName.equals("component")) { 267 currentGUIElementPath = atts.getValue("path"); 268 currentGUIElementParameters = new HashMap<String, String>(); 269 } 270 else if (qName.equals("event")) { 271 currentEventType = atts.getValue("type"); 272 currentEventParameters = new HashMap<String, String>(); 273 } 274 else if (qName.equals("param")) { 275 String paramName = atts.getValue("name"); 276 if (currentGUIElementPath != null) { 277 if ("parent".equals(paramName)) { 278 currentParentPath = atts.getValue("value"); 279 } 280 if ("class".equals(paramName)) { 281 currentGUIElementClass = atts.getValue("value"); 282 } 283 if ("index".equals(paramName)) { 284 currentGUIElementIndex = atts.getValue("value"); 285 } 286 currentGUIElementParameters.put(paramName, atts.getValue("value")); 287 } 288 else if (currentEventType != null) { 289 if ("target".equals(paramName)) { 290 currentEventSource = atts.getValue("value"); 291 } 292 if ("timestamp".equals(paramName)) { 293 currentEventTimestamp = Long.parseLong(atts.getValue("value")); 294 } 295 currentEventParameters.put(paramName, atts.getValue("value")); 296 } 297 else { 298 throw new SAXException("param tag found where it should not be."); 299 } 300 } 301 else { 302 throw new SAXException("unknown tag found: " + qName); 303 } 304 305 } 306 307 /* 308 * (non-Javadoc) 309 * 310 * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, 311 * java.lang.String) 312 */ 313 @Override 314 public void endElement(String uri, String localName, String qName) throws SAXException { 315 if (qName.equals("session")) { 316 if (currentSequence != null && !currentSequence.isEmpty()) { 317 sequences.add(currentSequence); 318 } 319 currentSequence = null; 320 } 321 else if (qName.equals("component") && currentGUIElementPath != null) { 322 HTMLGUIElementSpec guiElementSpec = 323 getGUIElementSpec(currentGUIElementClass, currentGUIElementParameters); 324 currentGUIElementTree.add(currentGUIElementPath, currentParentPath, guiElementSpec); 325 326 currentParentPath = null; 327 currentGUIElementPath = null; 328 currentGUIElementParameters = null; 329 } 330 else if (qName.equals("event")) { 331 IGUIElement currentGUIElement; 332 currentGUIElement = currentGUIElementTree.find(currentEventSource); 333 334 IEventType eventType = 335 HTMLEventTypeFactory.getInstance().getEventType(currentEventType, 336 currentEventParameters, 337 currentGUIElement); 338 Event event = 339 new Event(eventType, (currentGUIElement == null ? lastGUIElement 340 : currentGUIElement)); 341 342 event.setTimestamp(currentEventTimestamp); 343 HTMLGUIElement currentEventTarget = (HTMLGUIElement) event.getTarget(); 344 currentEventTarget.markUsed(); 345 currentSequence.add(event); 346 347 currentEventSource = null; 348 currentEventTimestamp = -1l; 349 currentEventParameters = null; 350 currentEventType = null; 351 352 if (currentGUIElement != null) { 353 lastGUIElement = currentGUIElement; 354 } 355 356 currentGUIElement = null; 357 } 358 } 359 360 /** 361 * <p> 362 * Returns a collection of event sequences that was obtained from parsing log files. 363 * </p> 364 * 271 * 272 * @param tagName 365 273 * @return 366 274 */ 367 public Collection<List<Event>> getSequences() { 368 return sequences; 369 } 370 371 /** 372 * <p> 373 * Returns the GUI model that is obtained from parsing log files. 374 * </p> 375 * 376 * @return GUIModel 377 */ 378 public GUIModel getGuiModel() { 379 return currentGUIElementTree.getGUIModel(); 380 } 381 382 /** 383 * Returns the HTMLGUIElementSpecification for a GUI Element described 384 * by its class name and its parameters. 385 * @param guiElementClass 386 * @param guiElementParameters 387 * @return 388 */ 389 private HTMLGUIElementSpec getGUIElementSpec(String guiElementClass, 390 Map<String, String> guiElementParameters) 391 { 392 HTMLGUIElementSpec specification = null; 393 if ("server".equals(guiElementClass)) { 394 // TODO: add correct port handling 395 specification = new HTMLServerSpec(guiElementParameters.get("htmlId"), 0); 396 currentServerSpec = (HTMLServerSpec) specification; 397 } 398 399 else { 400 String id = guiElementParameters.get("htmlId"); 401 if (id == null) { 402 HTMLPageElementSpec parentSpec = 403 (HTMLPageElementSpec) currentGUIElementTree.find(currentParentPath) 404 .getSpecification(); 405 id = parentSpec.getPage().getPagePath(); 406 } 407 408 int index = -1; 409 String indexStr = guiElementParameters.get("index"); 410 411 if ((indexStr != null) && (!"".equals(indexStr))) { 412 index = Integer.parseInt(indexStr); 413 } 414 String title = guiElementParameters.get("title"); 415 HTMLPageSpec page = new HTMLPageSpec(currentServerSpec, id, title); 416 specification = new HTMLPageElementSpec(page, guiElementClass, id, index); 417 } 418 419 return specification; 420 } 275 private boolean tagNameMustBeConsidered(String tagName) { 276 return 277 !"head".equals(tagName) && !"title".equals(tagName) && !"script".equals(tagName) && 278 !"style".equals(tagName) && !"link".equals(tagName) && !"meta".equals(tagName) && 279 !"iframe".equals(tagName) && !"input_hidden".equals(tagName) && 280 !"option".equals(tagName) && !"tt".equals(tagName) && !"br".equals(tagName) && 281 !"colgroup".equals(tagName) && !"col".equals(tagName); 282 283 } 284 421 285 } -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/eventcore/HTMLEventTypeFactory.java
r1059 r1069 23 23 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 24 24 import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 25 import de.ugoe.cs.autoquest.eventcore.gui.MouseDoubleClick; 25 26 import de.ugoe.cs.autoquest.eventcore.gui.Scroll; 26 27 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; … … 76 77 77 78 if ("onscroll".equals(eventName)) { 78 int[] coordinates = getCoordinateParameter(eventName, eventParameters); 79 int[] coordinates = 80 getCoordinateParameter("scrollX", "scrollY", eventName, eventParameters); 81 79 82 result = new Scroll(coordinates[0], coordinates[1]); 80 83 } 81 84 else if ("onclick".equals(eventName)) { 82 int[] coordinates = getCoordinateParameter( eventName, eventParameters);85 int[] coordinates = getCoordinateParameter("X", "Y", eventName, eventParameters); 83 86 result = 84 87 new MouseClick(MouseButtonInteraction.Button.LEFT, coordinates[0], coordinates[1]); 88 } 89 else if ("ondblclick".equals(eventName)) { 90 int[] coordinates = getCoordinateParameter("X", "Y", eventName, eventParameters); 91 result = new MouseDoubleClick 92 (MouseButtonInteraction.Button.LEFT, coordinates[0], coordinates[1]); 85 93 } 86 94 else if ("onchange".equals(eventName)) { … … 118 126 * @return 119 127 */ 120 private int[] getCoordinateParameter(String eventName, Map<String, String> eventParameters) { 121 String xCoord = eventParameters.get("X"); 128 private int[] getCoordinateParameter(String xParamName, 129 String yParamName, 130 String eventName, 131 Map<String, String> eventParameters) 132 { 133 String xCoord = eventParameters.get(xParamName); 122 134 if (xCoord == null) { 123 throw new IllegalArgumentException("eventParameters do not contain X coordinate."); 135 throw new IllegalArgumentException 136 ("eventParameters do not contain " + xParamName + " coordinate."); 124 137 } 125 138 126 String yCoord = eventParameters.get( "Y");139 String yCoord = eventParameters.get(yParamName); 127 140 if (yCoord == null) { 128 throw new IllegalArgumentException("eventParameters do not contain Y coordinate."); 141 throw new IllegalArgumentException 142 ("eventParameters do not contain " + yParamName + " coordinate."); 129 143 } 130 144 … … 134 148 } 135 149 catch (NumberFormatException e) { 136 throw new IllegalArgumentException("the coordinates provided " + " ofan " + eventName +150 throw new IllegalArgumentException("the coordinates provided by an " + eventName + 137 151 " event are no numbers"); 138 152 } -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLDocument.java
r1047 r1069 24 24 * @author Patrick Harms 25 25 */ 26 public class HTML Pageextends HTMLGUIElement implements IDialog {26 public class HTMLDocument extends HTMLGUIElement implements IDialog { 27 27 28 28 /** */ … … 37 37 * @param parent 38 38 */ 39 public HTML Page(HTMLPageSpec specification, HTMLServer parent) {39 public HTMLDocument(HTMLDocumentSpec specification, HTMLServer parent) { 40 40 super(specification, parent); 41 41 } … … 48 48 @Override 49 49 public String toString() { 50 return " Page(" + getPagePath() + ", \"" + getPageTitle() + "\")";50 return "Document(" + getPath() + ", \"" + getTitle() + "\")"; 51 51 } 52 52 … … 58 58 @Override 59 59 protected String getElementDescriptor() { 60 return " Page";60 return "Document"; 61 61 } 62 62 … … 69 69 */ 70 70 HTMLServerSpec getServer() { 71 return ((HTML PageSpec) super.getSpecification()).getServer();71 return ((HTMLDocumentSpec) super.getSpecification()).getServer(); 72 72 } 73 73 … … 79 79 * @return 80 80 */ 81 String getPa gePath() {82 return ((HTML PageSpec) super.getSpecification()).getPagePath();81 String getPath() { 82 return ((HTMLDocumentSpec) super.getSpecification()).getPath(); 83 83 } 84 84 … … 90 90 * @return 91 91 */ 92 String get PageTitle() {93 return ((HTML PageSpec) super.getSpecification()).getPageTitle();92 String getTitle() { 93 return ((HTMLDocumentSpec) super.getSpecification()).getTitle(); 94 94 } 95 95 -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLDocumentSpec.java
r1047 r1069 15 15 package de.ugoe.cs.autoquest.plugin.html.guimodel; 16 16 17 import java.net.URL;18 19 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; 20 18 … … 26 24 * @author Patrick Harms 27 25 */ 28 public class HTML PageSpec extends HTMLGUIElementSpec implements IGUIElementSpec {26 public class HTMLDocumentSpec extends HTMLGUIElementSpec implements IGUIElementSpec { 29 27 30 28 /** */ … … 35 33 36 34 /** */ 37 private String pa gePath;35 private String path; 38 36 39 37 /** */ 40 private String pageTitle; 38 private String query; 39 40 /** */ 41 private String title; 41 42 42 43 /** … … 49 50 * @param pageTitle 50 51 */ 51 public HTML PageSpec(HTMLServerSpec server, String pagePath, String pageTitle) {52 super(" page");52 public HTMLDocumentSpec(HTMLServerSpec server, String path, String query, String title) { 53 super("document"); 53 54 54 55 if (server == null) { 55 56 throw new IllegalArgumentException("server must not be null"); 56 57 } 57 else if (pa gePath == null) {58 else if (path == null) { 58 59 throw new IllegalArgumentException("pagePath must not be null"); 59 }60 else if (pageTitle == null) {61 throw new IllegalArgumentException("pageTitle must not be null");62 60 } 63 61 64 62 this.server = server; 65 this.pagePath = pagePath; 66 this.pageTitle = pageTitle; 67 } 68 69 /** 70 * <p> 71 * TODO: comment 72 * </p> 73 * 74 * @param server 75 * @param pagePath 76 * @param pageTitle 77 */ 78 public HTMLPageSpec(URL pageURL, String pageTitle) { 79 super("page"); 80 81 if (pageURL == null) { 82 throw new IllegalArgumentException("pageURL must not be null"); 83 } 84 else if (pageTitle == null) { 85 throw new IllegalArgumentException("pageTitle must not be null"); 86 } 87 88 this.server = new HTMLServerSpec(pageURL); 89 this.pagePath = pageURL.getPath(); 90 this.pageTitle = pageTitle; 63 this.path = path; 64 this.query = query; 65 this.title = title; 91 66 } 92 67 … … 96 71 @Override 97 72 public boolean getSimilarity(IGUIElementSpec other) { 98 if (other instanceof HTML PageSpec) {99 HTML PageSpec otherSpec = (HTMLPageSpec) other;73 if (other instanceof HTMLDocumentSpec) { 74 HTMLDocumentSpec otherSpec = (HTMLDocumentSpec) other; 100 75 101 76 if (!super.getSimilarity(otherSpec)) { … … 105 80 return false; 106 81 } 107 else if (!pagePath.equals(otherSpec.pagePath)) { 82 else if (!path.equals(otherSpec.path)) { 83 return false; 84 } 85 else if (query != null ? !query.equals(otherSpec.query) : otherSpec.query != null) { 108 86 return false; 109 87 } 110 88 else { 111 return pageTitle.equals(otherSpec.pageTitle);89 return (title != null ? title.equals(otherSpec.title) : otherSpec.title == null); 112 90 } 113 91 } … … 134 112 * @return 135 113 */ 136 String getPa gePath() {137 return pa gePath;114 String getPath() { 115 return path; 138 116 } 139 117 … … 145 123 * @return 146 124 */ 147 String getPageTitle() { 148 return pageTitle; 125 String getQuery() { 126 return query; 127 } 128 129 /** 130 * <p> 131 * TODO: comment 132 * </p> 133 * 134 * @return 135 */ 136 String getTitle() { 137 return title; 149 138 } 150 139 -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElement.java
r989 r1069 47 47 * @param parent 48 48 */ 49 public HTMLPageElement(HTMLPageElementSpec specification, HTML Pageparent) {49 public HTMLPageElement(HTMLPageElementSpec specification, HTMLDocument parent) { 50 50 super(specification, parent); 51 51 } … … 58 58 @Override 59 59 public String toString() { 60 String str = getTag ();60 String str = getTagName(); 61 61 62 if ((get TagId() != null) && (!"".equals(getTagId()))) {63 str += "(id=\"" + get TagId() + "\")";62 if ((getHtmlId() != null) && (!"".equals(getHtmlId()))) { 63 str += "(id=\"" + getHtmlId() + "\")"; 64 64 } 65 65 else { 66 str += "[" + get TagIndex() + "]";66 str += "[" + getIndex() + "]"; 67 67 } 68 68 … … 77 77 @Override 78 78 protected String getElementDescriptor() { 79 return getTag ();79 return getTagName(); 80 80 } 81 81 … … 87 87 * @return 88 88 */ 89 HTML PageSpec getPage() {89 HTMLDocumentSpec getPage() { 90 90 return ((HTMLPageElementSpec) super.getSpecification()).getPage(); 91 91 } … … 98 98 * @return 99 99 */ 100 String getTag () {101 return ((HTMLPageElementSpec) super.getSpecification()).getTag ();100 String getTagName() { 101 return ((HTMLPageElementSpec) super.getSpecification()).getTagName(); 102 102 } 103 103 … … 109 109 * @return 110 110 */ 111 String get TagId() {112 return ((HTMLPageElementSpec) super.getSpecification()).get TagId();111 String getHtmlId() { 112 return ((HTMLPageElementSpec) super.getSpecification()).getHtmlId(); 113 113 } 114 114 … … 120 120 * @return 121 121 */ 122 int get TagIndex() {123 return ((HTMLPageElementSpec) super.getSpecification()).get TagIndex();122 int getIndex() { 123 return ((HTMLPageElementSpec) super.getSpecification()).getIndex(); 124 124 } 125 125 -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElementSpec.java
r1059 r1069 30 30 31 31 /** */ 32 private HTML PageSpec page;32 private HTMLDocumentSpec page; 33 33 34 34 /** */ 35 private String tag ;35 private String tagName; 36 36 37 37 /** */ 38 private String id;38 private String htmlId; 39 39 40 40 /** */ … … 50 50 * @param id 51 51 */ 52 public HTMLPageElementSpec(HTML PageSpec page, String tag, String id, int index) {53 super(tag );52 public HTMLPageElementSpec(HTMLDocumentSpec page, String tagName, String htmlId, int index) { 53 super(tagName); 54 54 55 55 if (page == null) { 56 56 throw new IllegalArgumentException("page must not be null"); 57 57 } 58 else if (tag == null) {58 else if (tagName == null) { 59 59 throw new IllegalArgumentException("tag must not be null"); 60 60 } 61 else if (( id == null) && (index < 0)) {61 else if ((htmlId == null) && (index < 0)) { 62 62 throw new IllegalArgumentException 63 63 ("either id must not be null or the index must be greater or equal to 0"); … … 65 65 66 66 this.page = page; 67 this.tag = tag;68 this. id = id;67 this.tagName = tagName; 68 this.htmlId = htmlId; 69 69 this.index = index; 70 70 } … … 84 84 return false; 85 85 } 86 else if (!tag .equals(otherSpec.tag)) {86 else if (!tagName.equals(otherSpec.tagName)) { 87 87 return false; 88 88 } 89 89 90 if ( id != null) {91 return id.equals(otherSpec.id);90 if (htmlId != null) { 91 return htmlId.equals(otherSpec.htmlId); 92 92 } 93 93 else if (index >= 0) { … … 106 106 * @return 107 107 */ 108 public HTMLPageSpec getPage() {108 HTMLDocumentSpec getPage() { 109 109 return page; 110 110 } … … 117 117 * @return 118 118 */ 119 String getTag () {120 return tag ;119 String getTagName() { 120 return tagName; 121 121 } 122 122 … … 128 128 * @return 129 129 */ 130 String get TagId() {131 return id;130 String getHtmlId() { 131 return htmlId; 132 132 } 133 133 … … 139 139 * @return 140 140 */ 141 int get TagIndex() {141 int getIndex() { 142 142 return index; 143 143 } -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLServerSpec.java
r1059 r1069 14 14 15 15 package de.ugoe.cs.autoquest.plugin.html.guimodel; 16 17 import java.net.URL;18 16 19 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; … … 58 56 this.host = host; 59 57 this.port = port; 60 }61 62 /**63 * <p>64 * TODO: comment65 * </p>66 *67 * @param pageURL68 */69 public HTMLServerSpec(URL pageURL) {70 super("server");71 72 if (pageURL == null) {73 throw new IllegalArgumentException("page URL must not be null");74 }75 76 this.host = pageURL.getHost();77 this.port = pageURL.getPort();78 58 } 79 59
Note: See TracChangeset
for help on using the changeset viewer.