我想使用Create File关键字在文件中保存变量值。价值是一个浮动。当我尝试使用“创建文件”保存它时会出现错误
using System;
using System.Linq;
using System.Windows.Forms;
using mshtml;
// This code was written under the assumption that your form has a
// WebBrowser control named WebBrowser1,
// and that you have added the unmanaged MSHTML library as a reference to your project.
namespace WebClientDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(<your-url-here>);
}
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.Document == null)
return;
IHTMLDocument2 iDoc = (IHTMLDocument2)webBrowser1.Document.DomDocument;
HTMLSelectElement selectElement = iDoc?.all.OfType<HTMLSelectElement>()
.FirstOrDefault(s => s.name == "birthday.month");
if (selectElement != null)
{
selectElement.selectedIndex = 2;
}
}
}
}
答案 0 :(得分:3)
我认为你需要在编写之前将数字转换为字符串:
*** Settings ***
Library OperatingSystem
*** Test Cases ***
Write
${str}= Set Variable 3.1415926
${flt}= Convert To Number ${str}
${str2}= Convert To String ${flt}
Create File demo.txt ${str2}