Java中的Sikulix API停止了工作

时间:2016-02-25 07:45:21

标签: java

以下代码在今天早上的大部分时间都在工作,直到它决定我的Selenium库已经消失。从那以后我重新导入了我的库,但我的第一个Sikulix命令没有运行。这是我的Sikulux.input没有打开弹出窗口。任何人都可以看到这不起作用的原因吗?

package Exchange;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.*;
import org.sikuli.script.Screen;






public class ExchangeRateRead {

public static void main(String[]args)   throws FindFailed 
{

    Screen s = new Screen();
    WebDriver driver = new FirefoxDriver();
    String input = Sikulix.input("Select a time frame from: 12h, 1D, 1W, 1Y.");



        System.out.println(input);
        //Opens a page/graph based on user input.
        switch (input)
            {
                case "12h":
                {
                  driver.get("http://www.xe.com/currencycharts/?from=USD&to=ZAR&view=12h");
                  // Testing values
                    WebElement exchangeClose;
                    exchangeClose = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                    String close = exchangeClose.getText();
                    System.out.println("The Dollar against the Rand closed at " + close);

                  //First Movement    
                    s.mouseMove("start.png");


                  for (int i = 0; i <= 9; i++)
                    {
                        s.mouseMove(65, 0);
                        WebElement exchangeClosei;
                        WebElement exchangeTimei;
                        exchangeClosei = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                        exchangeTimei = driver.findElement(By.xpath("//div[@id='rates_detail_title']"));
                        String closei = exchangeClosei.getText();
                        String timei = exchangeTimei.getText();
                        System.out.println("The Dollar was worth " + closei + " Rands at " + timei);

                     }

                  break;
                }

                case "1D":
                {
                  driver.get("http://www.xe.com/currencycharts/?from=USD&to=ZAR&view=1D");
                  // Testing values
                    WebElement exchangeClose;
                    exchangeClose = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                    String close = exchangeClose.getText();
                    System.out.println("The Dollar against the Rand closed at " + close);
                  //Moving Mouse across Screen

                  //First Movement    
                    s.mouseMove("start.png");



                  for (int i = 0; i <= 9; i++)
                    {
                        s.mouseMove(65, 0);
                        WebElement exchangeClosei;
                        WebElement exchangeTimei;
                        exchangeClosei = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                        exchangeTimei = driver.findElement(By.xpath("//div[@id='rates_detail_title']"));
                        String closei = exchangeClosei.getText();
                        String timei = exchangeTimei.getText();
                        System.out.println("The Dollar was worth " + closei + " Rands at " + timei);

                     }
                  break;
                }

                case "1W":
                {
                  driver.get("http://www.xe.com/currencycharts/?from=USD&to=ZAR&view=1W");
                  // Testing values
                    WebElement exchangeClose;
                    exchangeClose = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                    String close = exchangeClose.getText();
                    System.out.println("The Dollar against the Rand closed at " + close);
                  //Moving Mouse across Screen

                  //First Movement    
                    s.mouseMove("start.png");


                  for (int i = 0; i <= 9; i++)
                    {
                        s.mouseMove(65, 0);
                        WebElement exchangeClosei;
                        WebElement exchangeTimei;
                        exchangeClosei = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                        exchangeTimei = driver.findElement(By.xpath("//div[@id='rates_detail_title']"));
                        String closei = exchangeClosei.getText();
                        String timei = exchangeTimei.getText();
                        System.out.println("The Dollar was worth " + closei + " Rands at " + timei);

                     }
                  break;
                }
                case "1Y":
                {
                  driver.get("http://www.xe.com/currencycharts/?from=USD&to=ZAR&view=1Y");
                  // Testing values
                    WebElement exchangeClose;
                    exchangeClose = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                    String close = exchangeClose.getText();
                    System.out.println("The Dollar against the Rand closed at " + close);
                  //Moving Mouse across Screen

                  //First Movement    
                    s.mouseMove("start.png");


                  for (int i = 0; i <= 9; i++)
                    {
                        s.mouseMove(65, 0);
                        WebElement exchangeClosei;
                        WebElement exchangeTimei;
                        exchangeClosei = driver.findElement(By.xpath("//div[@id='rates_detail_desc']/strong[2]"));
                        exchangeTimei = driver.findElement(By.xpath("//div[@id='rates_detail_title']"));
                        String closei = exchangeClosei.getText();
                        String timei = exchangeTimei.getText();
                        System.out.println("The Dollar was worth " + closei + " Rands at " + timei);

                     }
                  break;
                }
            }


}

}

1 个答案:

答案 0 :(得分:0)

解决了,Selenium.jar我用旧版本替换了非功能性的。较新的一个再次运作。