我正在尝试创建有效的网址:
private string Urlpath { get; set; }
Driver.Navigate().GoToUrl(Urlpath);
private void Button_URL(object sender, RoutedEventArgs e)
{
var dialog = new MyDialog();
if (dialog.ShowDialog() == true)
{
MessageBox.Show("Refreshing a URL requires you to select a folder.");
string Urlpath = dialog.ResponseText;
Status_HTML.Content = "Selected:" + "\n" + Urlpath + "\n" + "Save and/or edit any file in your folder to get started!";
}
}
Urlpath是来自http://localhost/laravel/project/public/之类的输入框的字符串值,但它表示它不是有效的网址。 实际上它说 System.ArgumentNullException:Argument' url'不能为空。因为它可能只接受有效的网址,但有一个字符串值。如何将此字符串转换为URL?
答案 0 :(得分:0)
您尚未为UrlPath
属性分配任何值,将所需的URL分配给UrlPath
属性,然后使用它传递给该方法。
Urlpath = "http://localhost/laravel/project/public/";
Driver.Navigate().GoToUrl(Urlpath);
EDIT
从UrlPath
分配dialog.ResponseText
属性后,您需要调用导航
私有字符串Urlpath {get;组; }
private void Button_URL(object sender, RoutedEventArgs e)
{
var dialog = new MyDialog();
if (dialog.ShowDialog() == true)
{
MessageBox.Show("Refreshing a URL requires you to select a folder.");
string Urlpath = dialog.ResponseText;
Status_HTML.Content = "Selected:" + "\n" + Urlpath + "\n" + "Save and/or edit any file in your folder to get started!";
Driver.Navigate().GoToUrl(Urlpath);
}
}