zoukankan      html  css  js  c++  java
  • QT 操作记录,待实践

    一、C++实现

        QWebFrame* frame = webView()->page()->currentFrame();
        if (frame!=NULL){
            QWebElementCollection collection1 = frame->findAllElements(“input[name=submit]”);
            foreach (QWebElement element, collection1){
    
                QPoint poss(element.geometry().center());
                QPoint pos = this->topLevelWidget()->mapToGlobal(QPoint(0,0));
                QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QApplication::sendEvent(webView->page(), &event0);
                QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QApplication::sendEvent(webView->page(), &event1);
            }
        }
    

    这种方法对于纯HTML的网页有效,但是javascript实现提交功能的网页不一定有效。

    二、javascript实现

    调用

    evaluateJavaScript(code);


    三、两者结合实现

        QWebFrame* frame = webView()->page()->currentFrame();
        if (frame!=NULL) {
            QWebElementCollection collection1 = frame->findAllElements(“input[name=submit]”);
            foreach (QWebElement element, collection1){
                element.evaluateJavaScript("this.click();");
            }
        }
    
    


     

  • 相关阅读:
    课堂训练
    测试用例
    学生空间测试
    图书管理系统为例5w1h
    风险分析
    关于选择方案的练习作业
    图书管理系统需求报告书
    电梯演说模板
    对于敏捷开发的见解
    课堂练习2
  • 原文地址:https://www.cnblogs.com/eaglezzb/p/4176463.html
Copyright © 2011-2022 走看看