• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.29
/src/main/java/com/meterware/httpunit/HTMLElementScriptable.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.httpunit;
9

10
import com.meterware.httpunit.scripting.DocumentElement;
11
import com.meterware.httpunit.scripting.ScriptableDelegate;
12

13
/**
14
 * The Class HTMLElementScriptable.
15
 */
16
class HTMLElementScriptable extends ScriptableDelegate implements DocumentElement {
17

18
    /** the element that I am scripting for. */
19
    private HTMLElement _element;
20

21
    /**
22
     * Gets the element.
23
     *
24
     * @return the _element
25
     */
26
    protected HTMLElement get_element() {
27
        return _element;
1✔
28
    }
29

30
    /**
31
     * get the property with the given name
32
     *
33
     * @param propertyName
34
     *            - the name of the property to get
35
     */
36
    @Override
37
    public Object get(String propertyName) {
38
        if (propertyName.equals("nodeName") || propertyName.equals("tagName")) {
1✔
39
            return _element.getTagName();
1✔
40
        }
41
        if (propertyName.equalsIgnoreCase("title")) {
1✔
42
            return _element.getTitle();
1✔
43
        }
44
        if (_element.isSupportedAttribute(propertyName)) {
1✔
45
            return _element.getAttribute(propertyName);
1✔
46
        }
47
        return super.get(propertyName);
1✔
48
    }
49

50
    /**
51
     * get the content of the given attribute.
52
     *
53
     * @param attributeName
54
     *            the attribute name
55
     *
56
     * @return the attribute as a string
57
     */
58
    public String getAttribute(String attributeName) {
59
        return _element.getAttribute(attributeName);
1✔
60
    }
61

62
    /**
63
     * set the attribute with the given attribute name to the given value.
64
     *
65
     * @param attributeName
66
     *            the attribute name
67
     * @param value
68
     *            the value
69
     */
70
    public void setAttribute(String attributeName, Object value) {
71
        _element.setAttribute(attributeName, value);
1✔
72
    }
1✔
73

74
    /**
75
     * remove the given attribute.
76
     *
77
     * @param attributeName
78
     *            the attribute name
79
     */
80
    public void removeAttribute(String attributeName) {
81
        _element.removeAttribute(attributeName);
×
82
    }
×
83

84
    @Override
85
    public boolean handleEvent(String eventName) {
86
        // check whether onclick is activated
87
        if (eventName.equalsIgnoreCase("onclick")) {
1✔
88
            handleEvent("onmousedown");
1✔
89
        }
90
        String eventScript = getAttribute(eventName);
1✔
91
        boolean result = doEventScript(eventScript);
1✔
92
        if (eventName.equalsIgnoreCase("onclick")) {
1✔
93
            handleEvent("onmouseup");
1✔
94
        }
95
        return result;
1✔
96
    }
97

98
    /**
99
     * construct me from a given element.
100
     *
101
     * @param element
102
     *            the element
103
     */
104
    public HTMLElementScriptable(HTMLElement element) {
1✔
105
        _element = element;
1✔
106
    }
1✔
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc