Project

General

Profile

« Previous | Next » 

Revision ee5d420b

Added by Andreas Kohlbecker almost 5 years ago

ref #4372 page elements DupalBlock and FeatureBlock compatible also with zen theme - solving problems

View differences:

src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
47 47

  
48 48
    private final List<WebElement> descriptionItemElements;
49 49

  
50
    private WebElement titleElement;
51

  
52
    private WebElement contentContainer;
53

  
50
    protected List<WebElement> featureBlockelements;
54 51

  
55 52
    /**
56 53
     *
......
125 122
        return titleElement;
126 123
    }
127 124

  
128
    @Override
129
    public WebElement getContent() {
130
        return contentContainer;
125
    public FeatureBlock(WebDriver driver, WebElement element, String enclosingTag, String ... elementTags) {
126
        this(driver, element, false, enclosingTag, elementTags);
131 127
    }
132 128

  
129
    public FeatureBlock(WebDriver driver, WebElement element, boolean hasHiddenTitle, String enclosingTag, String ... elementTags) {
133 130

  
134
    public FeatureBlock(WebDriver driver, WebElement element, String enclosingTag, String ... elementTags) {
135

  
136
        super(element);
131
        super(element, hasHiddenTitle);
137 132
//        logger.setLevel(Level.TRACE);
138 133
        logger.trace("FeatureBlock() - constructor after super()");
139 134

  
140 135
        this.driver = driver;
141 136
        this.elementTags = elementTags;
142 137

  
143
        titleElement =  element.findElement(By.className("title"));
138
        WebElement featureBlockElementsWrapper =  element.findElement(By.className("feature-block-elements"));
144 139

  
145
        contentContainer = element.findElement(By.className("content"));
140
        featureBlockelements = element.findElements(By.className("feature-block-element"));
146 141

  
147
        WebElement descriptionElementsRepresentation =  element.findElement(By.className("feature-block-elements"));
148
        featureType = descriptionElementsRepresentation.getAttribute("id");
142
        featureType = featureBlockElementsWrapper.getAttribute("id");
149 143

  
150 144
        //TODO throw exception instead of making an assertion! selenium should have appropriate exceptions
151
        assertEquals("Unexpected tag enclosing description element representations", enclosingTag, descriptionElementsRepresentation.getTagName());
145
        assertEquals("Unexpected tag enclosing description element representations", enclosingTag, featureBlockElementsWrapper.getTagName());
152 146

  
153 147
        logger.trace("FeatureBlock() - loading all elements ...");
154 148
        descriptionItemElements = new ArrayList<WebElement>();
......
158 152
            HashMap<String, List<WebElement>> elementsByTag = new HashMap<String, List<WebElement>>();
159 153
            Integer lastSize = null;
160 154
            for (String elementTag : elementTags) {
161
                List<WebElement> foundElements = descriptionElementsRepresentation.findElements(By.tagName(elementTag));
155
                List<WebElement> foundElements = featureBlockElementsWrapper.findElements(By.tagName(elementTag));
162 156
                if(lastSize != null && foundElements.size() != lastSize){
163 157
                    throw new NoSuchElementException("Mulitpart element lists differ in size");
164 158
                }
......
176 170
        } else {
177 171
            // handle single elements
178 172
            String elementTag = elementTags[0];
179
            for(WebElement el : descriptionElementsRepresentation.findElements(By.tagName( elementTag ))) {
173
            for(WebElement el : featureBlockElementsWrapper.findElements(By.tagName( elementTag ))) {
180 174
                descriptionItemElements.add(el);
181 175
//                descriptionElements.add(new DescriptionElementRepresentation(el));
182 176
            }
......
186 180
    }
187 181

  
188 182

  
183
    public List<WebElement> getFeatureBlockElements() {
184
        return featureBlockelements;
185
    }
186

  
187

  
189 188
    private Long jsCountElements(String jQuerySelector) {
190 189
        if(driver instanceof JavascriptExecutor) {
191 190
            String blockId = getElement().getAttribute("id");

Also available in: Unified diff