Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导航/打开存储在SeleniumWebDriver变量中的HTML源代码_Selenium_C# 3.0 - Fatal编程技术网

导航/打开存储在SeleniumWebDriver变量中的HTML源代码

导航/打开存储在SeleniumWebDriver变量中的HTML源代码,selenium,c#-3.0,Selenium,C# 3.0,Selenium webdriver可以导航到给定的URL,但找不到如何导航/打开存储在变量中的HTML源代码?好的,我认为还有一种替代方法,可能这可以帮助其他人。我们可以将字符串(具有html源代码)写入文件并另存为“.html”,如下所示: StreamWriter SW = new StreamWriter(Environment.CurrentDirectory + "\\temp.html"); SW.Write(richTextBox1.Text);

Selenium webdriver可以导航到给定的URL,但找不到如何导航/打开存储在变量中的HTML源代码?

好的,我认为还有一种替代方法,可能这可以帮助其他人。我们可以将字符串(具有html源代码)写入文件并另存为“.html”,如下所示:

 StreamWriter SW = new StreamWriter(Environment.CurrentDirectory + "\\temp.html");
            SW.Write(richTextBox1.Text);
            SW.Close();
然后,我们可以用webdriver(例如chrome)打开它,如下所示:

ChromeDriver ChDriver = new ChromeDriver();
ChDriver.Navigate().GoToUrl("file:///" + Environment.CurrentDirectory + "\\temp.html");
最好知道是否有一种直接的方法来使用webdriver