Use selenium with C

ε祈祈猫儿з 提交于 2020-02-29 06:42:28

问题


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?

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


回答1:


No. Here is a list of official Selenium bindings, and here is a list of unofficial selenium bindings. C is not listed on either.




回答2:


From the official page of Selenium:

  • The core language-specific client drivers are:
    • Ruby
    • JavaScript
    • Java
    • Python
    • C#

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]

Solution

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++

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

  • Chainable commands
  • Value-like objects compatible with STL containers
  • Header-only
  • Lightweight dependencies:
    • libcurl
    • picojson
  • Can be used with any testing framework
  • Linux, Mac and Windows
  • clang (3.4), GCC (4.6) and Visual Studio (2010)

An example:

#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 in his comment clearly mentions:

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.



来源:https://stackoverflow.com/questions/59635233/use-selenium-with-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!