三生石@ 2015-01-22 08:16 采纳率: 100%
浏览 45

将硒与Ajax一起使用

While uploading file in http://pdftableconverter.com/ with selenium

I have a problem to download file converted

to download xls file I need to click on the Like button which found in ajax web page check link to open image to see the problem https://drive.google.com/file/d/0B4cxDnPAjctLOFcyZ29xeENHSG8/view?usp=sharing

My problem i need to click the like button to download the xls file

 WebDriver driver = new FirefoxDriver();
        driver.get("http://pdftableconverter.com/");
        File file=null;

        try {
            file = new         File(SeleniumProg.class.getClassLoader().getResource("21.pdf").toURI());

        Assert.assertTrue(file.exists()); 
        System.out.println("File Exited");


        driver.findElement(By.name("userfile")).sendKeys(file.getAbsolutePath());

        WebElement browseButton = driver.findElement(By.id("uploadButton"));
        new Actions(driver).click(browseButton).perform();

           //put path to your image in a clipboard
            StringSelection ss = new StringSelection(file.getAbsolutePath());


                        //To Clear User Selection


            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);

            //imitate mouse events like ENTER, CTRL+C, CTRL+V
            Robot robot = new Robot();
            robot.keyPress(KeyEvent.VK_ENTER);
            robot.keyRelease(KeyEvent.VK_ENTER);
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_ENTER);
            robot.keyRelease(KeyEvent.VK_ENTER);

            WebElement d = driver.findElement(By.id("email"));
            d.sendKeys("osama70087@gmail.com");





            driver.findElement(By.id("submit_form")).click();
            System.out.println("kkkkkkkk");
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器