将硒与 C 一起使用 [英] Use selenium with C

查看:40
本文介绍了将硒与 C 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到关于您是否可以在 C 中使用 selenium 的任何信息.只是 C,而不是 C#.有谁知道这是否可能?

I can't find any information on if you can use selenium with C. Just C, not c#. Does anyone know if this is possible?

我尝试在 Google 上搜索,但出现的所有结果中都包含C#"而不是C".

I tried searching on Google but all results that appear has "C#" in it and not "C".

推荐答案

来自官方页面Selenium:

  • 特定于语言的核心客户端驱动程序是:
  • 红宝石
  • JavaScript
  • Java
  • Python
  • C#

然而,根据 Selenium 官方主页确实存在其他语言的语言绑定,但这些项目是Selenium 项目不支持、维护、托管或认可,具体如下:

However as per Selenium Official Home Page language bindings for other languages does exist but those projects are not supported, maintained, hosted, or endorsed by the Selenium project, which are as follows:

  • Selenium [Language: Go]
  • hs-webdriver [Language: Haskell]
  • wd [Language: JavaScript]
  • Selenium-Remote-Driver [Language: Perl]
  • php-webdriver [Language: PHP]
  • RSelenium [Language: R]
  • webdriver.dart [Language: Dart]

您始终可以使用任何核心语言编写基于 WebDriver 的测试,例如Java/Python/C# 并从您的 C/C++ 应用程序调用脚本.

You could always write your WebDriver based tests in any of the core language e.g. Java/Python/C# and call the script from your C / C++ application.

Webdriver++ 是 Selenium Webdriver 的 C++ 客户端库,您必须安装它并具有以下功能支持:

Webdriver++ is a C++ client library for Selenium Webdriver which you have to install and have the following feature support:

  • 可链接的命令
  • 与 STL 容器兼容的类值对象
  • 仅限标题
  • 轻量级依赖:
  • libcurl
  • picojson
  • 可用于任何测试框架
  • Linux、Mac 和 Windows
  • clang (3.4)、GCC (4.6) 和 Visual Studio (2010)

示例:

#include <webdriverxx/webdriverxx.h>
using namespace webdriverxx;

int main() {
    WebDriver firefox = Start(Firefox());
    firefox
    .Navigate("http://google.com")
    .FindElement(ByCss("input[name=q]"))
    .SendKeys("Hello, world!")
    .Submit();
    return 0;    
}


@JimEvans 在他的评论中明确提到:

如果你真的不在乎你不是在真正的"跑步浏览器,那么直接使用 QtWebKit 可能是一个不错的选择.意识到,虽然这不是一项微不足道的事业.据我所知,WebDriver 没有任何 C++ 语言绑定,但只要你有一个 JSON 解析库(json-cpp 很不错)和一个 HTTP 客户端库,你就可以在订单很短.

If you really don't care that you're not running in a "real" browser, then directly consuming QtWebKit might be a good choice. Realize, though that it's not a trivial undertaking. There aren't any C++ language bindings for WebDriver, as far as I know, but as long as you have a JSON parsing library (json-cpp is pretty good), and an HTTP client library, you can write your own language bindings in pretty short order.

这篇关于将硒与 C 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆