我需要从下拉菜单中选择一个元素.
例如,打开这个:
<select id="fruits01" class="select" name="fruits">
<option value="0">Choose your fruits:</option>
<option value="1">Banana</option>
<option value="2">Mango</option>
</select>
Run Code Online (Sandbox Code Playgroud)
所以首先我要点击它.我这样做:
inputElementFruits = driver.find_element_by_xpath("//select[id='fruits']").click()
Run Code Online (Sandbox Code Playgroud)(好吧,打开菜单)
Mango但它没有用.我正面临这个问题; 我知道这个问题已经出现了,我已经尝试了所提到的解决方案,因此请问我的配置和代码.
之前脚本正在运行,但现在它们不是,所以我尝试制作一个基本的开放浏览器脚本.
最新版本的Selenium WebDriver:http://selenium-release.storage.googleapis.com/3.5/selenium-java-3.5.0.zip
ChromeDriver上的最新版本:http://chromedriver.storage.googleapis.com/index.html?path = 2.31 /
基本打开浏览器代码:
package Trial;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Trial_Class {
public static void main(String args[]){
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.youtube.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到以下错误:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 43967
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide …Run Code Online (Sandbox Code Playgroud) 只是为了表明我已经尽了应有的努力,对于以下问题,我已经尝试了建议的答案,或者至少仔细阅读并尝试理解它们:
Selenium:WebDriverException:Chrome 无法启动:由于 google-chrome 不再运行而崩溃,因此 ChromeDriver 假设 Chrome 已崩溃
从 chrome 位置 C:\..\Chrome\Application\chrome.exe 启动的进程不再运行,因此 ChromeDriver 假设 Chrome 已崩溃
通过docker使用Selenium python库,Chrome报错无法启动:异常退出
使用 Selenium 时 Chrome 崩溃(没有发布答案,但我仍然查看过)
如何修复 Linux 中的“usr/bin/google-chrome 不再运行,因此 ChromeDriver 假设 Chrome 已崩溃”错误? - 对于这个,我用“/etc/alternatives/google-chrome”替换了“/usr/bin/google-chrome”,但仍然不起作用。
从 chrome 位置 /usr/bin/google-chrome 启动的进程不再运行,因此 ChromeDriver 假设 Chrome 因 Selenium 崩溃了
python linux selenium:无法访问 chrome
未知错误:Chrome 无法启动:崩溃(selenium,无头模式)
python selenium: WebDriverException: 消息: chrome 无法访问
WebDriverException:消息:未知错误:Chrome 无法启动:在 VPS 上通过 Python 使用 ChromeDriver Chrome 和 Selenium 异常退出