Bonjour,

J'ai une erreur avec l'utilisation d'un WebDriver. Je parviens à accéder au reste de la page sauf pour un bouton alors qu'avec Selenium cela fonctionne.

L'erreur intervient à la fin du code quand je veux accéder à : "button.300Expiry"

Mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    UrlBrocker = "http://www.optionweb.com";
    Brocker = new FirefoxDriver();
    Brocker.get(UrlBrocker);
    Brocker.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
//    Brocker.manage().timeouts().pageLoadTimeout(240, TimeUnit.SECONDS);
 
    // connexion
    for (int second = 0;; second++) {
        if (second >= 60) fail("timeout");
        try { if (Brocker.findElement(By.id("email_for_login")).isDisplayed()) break; } 
            catch (Exception e) {}
 
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
System.out.print ("\ncnx ok");
 
    Brocker.findElement(By.id("email_for_login")).clear();
    Brocker.findElement(By.id("email_for_login")).sendKeys("lanow72@gmail.Com");
    Brocker.findElement(By.cssSelector("form.loginForm > input[name=\"password\"]")).sendKeys("yvco7311op");
    Brocker.findElement(By.name("sendit")).click();  
 
    // home
//    Brocker.findElement(By.linkText("lu")).click();
    //Brocker.findElement(By.name("sendit")).click();  
    Brocker.findElement(By.id("menu-item-4031")).click();
System.out.print ("\nhome ok");
 
    // Attente court term
    /*for (int second = 0;; second++) {
    //      System.out.print(second +  "court terme");
            if (second >= 60) fail("timeout");
    //        try { if (isElementPresent(Brocker, By.id("zoneTab_sixtySeconds"))) break; } catch (Exception e) {}
            try { if (isElementPresent(Brocker, By.id("zoneTab_longTerm"))) break; } catch (Exception e) {}
                  try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
 
    Brocker.findElement(By.id("zoneTab_sixtySeconds")).click();
    System.out.print ("\ncourt term ok");
*/
//    driver.findElement(By.cssSelector("a.chzn-single.chzn-single-with-drop > span")).click();
 //   Brocker.findElement(By.cssSelector("a.chzn-single > span")).click();
//    Brocker.findElement(By.id("assetPlatformSelect_0_chzn_o_10")).click();
    System.out.print ("\npaire ok");
 
 
    for (int second = 0;; second++) {
        if (second >= 60) fail("timeout");
        try { if (Brocker.findElement(By.id("zoneTab_sixtySeconds")).isDisplayed()) break; } catch (Exception e) {}
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
    Brocker.findElement(By.id("zoneTab_sixtySeconds")).click();
    System.out.print ("\n click short term");
 
    for (int second = 0;; second++) {
        if (second >= 60) fail("timeout");
        try { if (Brocker.findElement(By.cssSelector("button.300Expiry")).isDisplayed()) break; } catch (Exception e) {}
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    By ident;
    ident = By.cssSelector("button.300Expiry");
    System.out.print("\nlllllllllllll" + ident);
    WebElement we = Brocker.findElement(ident);  // ERREUR ERREUR
    we.click();
Quelqu'un saurait-il m'indiquer comment corriger ce problème ?

Merci d'avance pour votre aide.