小编Rin*_*gil的帖子

必须通过webdriver.ie.driver系统属性设置驱动程序可执行文件

我正在使用Selenium来自动化测试.我的应用程序专门使用IE,它不适用于其他浏览器.

码:

import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Test {
    public static void main(String[] args) {
        final String sUrl = "http://www.google.co.in/";                             
        System.setProperty("webdriver.chrome.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe");
        WebDriver oWebDriver = new InternetExplorerDriver();
        oWebDriver.get(sUrl);
        WebElement oSearchInputElem = oWebDriver.findElement(By.name("q")); // Use name locator to identify the search input field.
        oSearchInputElem.sendKeys("Selenium 2");
        WebElement oGoogleSearchBtn = oWebDriver.findElement(By.xpath("//input[@name='btnG']"));  
        oGoogleSearchBtn.click();

        try {
            Thread.sleep(5000);
        } catch(InterruptedException ex) {
            System.out.println(ex.getMessage());
        }
        oWebDriver.close();
    }    
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误

必须通过webdriver.ie.driver系统属性设置驱动程序可执行文件的路径; 有关更多信息,请参阅https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.最新版本可以从http://www.seleniumhq.org/download/ 2012年6月12日下午4:18:42 下载org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO:I/O异常(java.处理请求时捕获的net.SocketException:软件导致连接中止:recv失败2012年6月12日下午4:18:42 org.apache.http.impl.client.DefaultRequestDirector tryExecute

有人可以帮我吗?

java internet-explorer webdriver system-properties selenium-webdriver

57
推荐指数
2
解决办法
22万
查看次数

如何在dotnet核心中运行F#interactive(fsi.exe)?它支持吗?

我无法在windows或linux上运行find/run fsi.exe.它无处可寻.也许它不受支持?

.net linux f# f#-interactive .net-core

23
推荐指数
2
解决办法
2343
查看次数

比较与泛型有关的工作方式

我偶然发现了一些"奇怪的行为".我使用F#interactive来测试一些代码并编写

Seq.zip "ACT" "GGA" |> Seq.map ((<||) compare)
// val it : seq<int> = seq [-1; -1; 1]
Run Code Online (Sandbox Code Playgroud)

然后我想用它制作一个函数并写下来

let compute xs ys = Seq.zip xs ys |> Seq.map ((<||) compare)
// val compute : xs:seq<'a> -> xs:seq<'a> -> seq<int> when 'a : comparison
Run Code Online (Sandbox Code Playgroud)

这推广了第一段代码,我认为这是件好事......直到我尝试使用它

compute "ACT" "GGA"
// val it : seq<int> = seq [-6; -4; 19]
Run Code Online (Sandbox Code Playgroud)

因此,compare当存在不同的"观点"(显式类型与泛型)时,以某种方式对"相同的事物"采取不同的行为

我知道如何解决它:要么通过明确的类型

let compute (xs: #seq<char>) // ... or char seq or string
Run Code Online (Sandbox Code Playgroud)

或者保持类型通用并与sign函数组合

let compute (* ... …
Run Code Online (Sandbox Code Playgroud)

generics comparison f#

13
推荐指数
1
解决办法
71
查看次数

在seq builder中枚举时,F#如何知道bitArray元素是bool?

    seq{
        for bit in BitArray(10) do 
        yield bit
    }
Run Code Online (Sandbox Code Playgroud)

bitbool类型的.我检查了ILSpy,并在其中一个闭包中添加了一个显式的强制转换.

BitArray仅实现普通(非通用)IEnumerable.F#如何知道它是一个bool

f#

13
推荐指数
1
解决办法
124
查看次数

在自定义计算表达式中实现绑定

我试图通过实现我自己的一个来学习更多关于F#的计算表达式.但是,我遇到了与该Bind方法有关的绊脚石.这是我到目前为止所得到的:

type public op<'a> = Op of ('a list -> 'a list)

let inline (>>) (Op a) (Op b) = Op (a >> b)

module Op =
    let id = Op id
    let bind (b : 'b -> op<'a>) (v : 'b) = b v
    let call (Op f) = f
    let push v = Op (fun t -> v :: t)
    // .. snip  ..

type OpBuilder() =
    member __.Bind (v, b) = Op.bind b v
    member …
Run Code Online (Sandbox Code Playgroud)

.net f# computation-expression

9
推荐指数
2
解决办法
177
查看次数

.NET接口允许来自非派生类型的隐式强制转换

当我注意到这个奇怪的部分时,我正在阅读Roslyn源代码:

    // Implicit casts are not emitted. As a result verifier may operate on a different 
    // types from the types of operands when performing stack merges in coalesce/ternary.
    // Such differences are in general irrelevant since merging rules work the same way
    // for base and derived types.
    //
    // Situation becomes more complicated with delegates, arrays and interfaces since they 
    // allow implicit casts from types that do not derive from them. In such cases
    // …
Run Code Online (Sandbox Code Playgroud)

.net c# interface

8
推荐指数
1
解决办法
148
查看次数

迭代数组与列表的性能

这个问题的启发,我想看看迭代一个数组与一个List之间是否有任何性能差异.

由于我们将迭代整个集合,我最初的想法是两者之间不应该存在性能差异.此外,我认为使用尾递归函数进行计数应该与使用可变变量一样快.但是,当我编写一个简单的脚本来测试差异时,我发现了以下内容(在VS2015的发布模式下运行):

add_k_list, elapsed 15804 ms, result 0L
add_k_list_mutable, elapsed 12800 ms, result 0L
add_k_array, elapsed 15719 ms, result 0L
Run Code Online (Sandbox Code Playgroud)

我想知道为什么使用可变变量的列表添加实现比尾递归版本和使用可变变量和数组的版本快得多.

这是我的代码:

open System.Diagnostics

let d = 100000
let n = 100000

let stopWatch = 
  let sw = Stopwatch ()
  sw.Start ()
  sw

let testList = [1..d]
let testArray = [|1..d|]

let timeIt (name : string) (a : int ->  int list -> 'T) : unit = 
  let t = stopWatch.ElapsedMilliseconds
  let v = a 0 (testList)
  for …
Run Code Online (Sandbox Code Playgroud)

performance f#

7
推荐指数
1
解决办法
396
查看次数

在F#中,如何在更大的管道环境中使用Seq.unfold?

我有一个包含两列,文本和计数的CSV文件.目标是从这里转换文件:

some text once,1
some text twice,2
some text thrice,3
Run Code Online (Sandbox Code Playgroud)

对此:

some text once,1
some text twice,1
some text twice,1
some text thrice,1
some text thrice,1
some text thrice,1
Run Code Online (Sandbox Code Playgroud)

重复每一行计数次数并将计数分布在那么多行上.

在我看来,这似乎是Seq.unfold的一个很好的候选者,在我们读取文件时生成了额外的行.我有以下生成器功能:

let expandRows (text:string, number:int32) =
    if number = 0 
    then None
    else
        let element = text                  // "element" will be in the generated sequence
        let nextState = (element, number-1) // threaded state replacing looping 
        Some (element, nextState)
Run Code Online (Sandbox Code Playgroud)

FSI产生以下函数签名:

val expandRows : text:string * number:int32 -> (string * (string * …
Run Code Online (Sandbox Code Playgroud)

f# seq.unfold

7
推荐指数
2
解决办法
218
查看次数

F# HTML 提供程序按列迭代表

有没有办法按表的列而不是按行进行迭代?API示例在行中有结算日期信息:

Settlement Day,Period,IMBALNGC,Offer Volume Bid Volume,Accepted Offer Vol,Accepted Bid Vol,UAOV,UABV,PAOV,PABV
2014-01-14,1,877.000,52378.500,-53779.500,348.200,-654.374,0.000,0.000,348.200,-654.374 
2014-01-14,2,196.000,52598.000,-53559.500,349.601,-310.862,0.000,0.000,316.701,-310.862 
2014-01-14,3,-190.000,52575.000,-53283.500,186.183,-2.426,0.000,0.000,162.767,-1.917 
2014-01-14,4,-61.000,52576.000,-53454.500,18.000,-24.158,0.000,0.000,18.000,-24.158 
Run Code Online (Sandbox Code Playgroud)

但是,如果结算日信息在列中,有没有一种方法可以执行类似于 API 示例的操作,如下所示:

let firstCol = mrktDepth.Columns|> Seq.head
let settlementDate = firstCol.``Settlement Day``
let acceptedBid = firstCol.``Accepted Bid Vol``
let acceptedOffer = firstCol.``Accepted Offer Vol``
Run Code Online (Sandbox Code Playgroud)

f# f#-data

5
推荐指数
0
解决办法
141
查看次数

.NET Standard F#库不能正确存储非英文字符

我使用以下代码使用F#4.3.4(我还使用4.5测试)创建了一个.NET Standard F#库:

namespace ClassLibrary2

module Say =
    let a = "?".Length.ToString()
    let b = sprintf "%A" ("?".ToCharArray() |> Array.map int)
    let c = "?"
Run Code Online (Sandbox Code Playgroud)

从其他项目(.net核心或.net框架)引用该库时:

Console.WriteLine(Say.a); // F# .net standard
Console.WriteLine(Say.b);
Console.WriteLine(Say.c == "?");
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

2
[|65533; 65533|]
False
Run Code Online (Sandbox Code Playgroud)

等效的C#.NET标准库:

using System;
using System.Linq;

namespace ClassLibrary1
{
    public static class Class1
    {
        public static string a = "?".Length.ToString();
        public static string b = String.Join(", ", "?".ToCharArray().Select(i => ((int)i).ToString()));
        public static string c = "?";
    }
}
Run Code Online (Sandbox Code Playgroud)

给出预期的输出:

1 
22269 …
Run Code Online (Sandbox Code Playgroud)

c# f# localization .net-standard

5
推荐指数
0
解决办法
102
查看次数

异步 - 等待进度条和交叉线程问题

我一直在使用异步的进度条并在C#中等待.我Form1.cs使用以下代码制作了一个简单的表单:

public partial class Form1 : Form
{
    private Progress<TaskAsyncExProgress> progress;
    public Form1(Progress<TaskAsyncExProgress> progress = null)
    {
        InitializeComponent();
        if (progress == null)
        {
            this.progress = new Progress<TaskAsyncExProgress>();
        }
        else
        {
            this.progress = progress;
        }

        this.progress.ProgressChanged += (s, e) =>
        {
            Debug.WriteLine("Progress: " + e.ProgressPercentage + "%");

            progressBar.Value += e.ProgressPercentage;

            txtResult.Text += e.Text;
        };

        Shown += async (s, e) =>
        {
            try
            {
                await Task.Run(() => HardTask(progress));
                txtResult.Text += "Done!";
            }
            finally
            {
                MessageBox.Show("Done!");
                Close();
            }
        };
    }

    void …
Run Code Online (Sandbox Code Playgroud)

c# async-await

2
推荐指数
1
解决办法
724
查看次数

使用泛型类型和静态成员的意外编译器警告

我想创建自己的列表类型CountedList<'T>,其中包含一个普通的F#列表以及列表中#元素的计数(因此我不必遍历整个列表来获取元素数).

这是我的尝试:

type CountedList<'T> = {List: 'T list; Count: int}
                        static member Empty<'a> () = {List=List.empty<'a>; Count=0}
                        member this.AddOne(element) = {this with List=element::this.List; Count=this.Count + 1}
Run Code Online (Sandbox Code Playgroud)

我们的想法是从某种类型的CountList.Empty开始,然后通过AddOne方法添加一个元素.

但是,当我尝试使用以下方法创建空列表时:

let emptyDoubleList = CountedList.Empty<double>()   
Run Code Online (Sandbox Code Playgroud)

我收到以下警告:

The instantiation of the generic type 'CountedList' is missing and can't be inferred from the arguments or return type of this member. Consider providing a type instantiation when accessing this type, e.g. 'CountedList<_>'.
Run Code Online (Sandbox Code Playgroud)

然而直接这样做:

let directEmptyDoubleList = {List=List.empty<double>; Count=0}
Run Code Online (Sandbox Code Playgroud)

没有给出警告.

为什么我会收到此警告?编译器是否应该能够意识到它是一个CountedList?此外,任何有关如何改进我的CountedList实现的建议也将受到赞赏.

这是完整的代码示例:

type …
Run Code Online (Sandbox Code Playgroud)

generics f#

1
推荐指数
1
解决办法
73
查看次数