Project

General

Profile

Download (1.95 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2020 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.dataportal.elements;
10

    
11
import org.openqa.selenium.By;
12
import org.openqa.selenium.WebDriver;
13
import org.openqa.selenium.WebElement;
14
import org.openqa.selenium.support.ui.ExpectedConditions;
15
import org.openqa.selenium.support.ui.WebDriverWait;
16

    
17
/**
18
 * @author a.kohlbecker
19
 * @since Aug 13, 2020
20
 */
21
public class Dynabox extends BaseElement {
22

    
23
    private WebDriver driver;
24

    
25
    private long timeOutInSeconds = 10;
26

    
27
    private By ajaxContentSelector;
28

    
29
    private LinkElement link;
30

    
31
    private BaseElement contentElement = null;
32

    
33

    
34
    /**
35
     * the inner content content element in {@code <div id="dynabox-(uuid)-content"><div class="dynabox-content-inner"><div class="content>}
36
     * which is loaded asynchronously after clicking the link element of the dynabox
37
     */
38
    public BaseElement getContentElement() {
39
        return contentElement;
40
    }
41

    
42
    public Dynabox(WebElement element, WebDriver driver) {
43
        super(element);
44
        this.driver = driver;
45

    
46
        ajaxContentSelector = By.cssSelector("#" + element.getAttribute("id") + "-content .content ");
47
        link = new LinkElement(element.findElement(By.tagName("a")));
48
    }
49

    
50

    
51
    public BaseElement click() {
52

    
53
        WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
54
        link.getElement().click();
55
        wait.until(ExpectedConditions.presenceOfElementLocated(ajaxContentSelector));
56
        contentElement = new BaseElement(getElement().findElement(ajaxContentSelector));
57
        return contentElement;
58
    }
59

    
60

    
61
    public long getTimeOutInSeconds() {
62
        return timeOutInSeconds;
63
    }
64

    
65

    
66
    public void setTimeOutInSeconds(long timeOutInSeconds) {
67
        this.timeOutInSeconds = timeOutInSeconds;
68
    }
69

    
70

    
71
}
(7-7/23)