我正在尝试在我的电脑上安装硒,所以我尝试了这些:
pip install selenium
Run Code Online (Sandbox Code Playgroud)
然后我去了这个网站下载geckodriver并将其复制到/usr/bin.
测试硒是否有效.我运行这些代码并得到一个错误(30秒后).
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('http://www.python.org')
assert 'Python' in driver.title
elem = driver.find_element_by_name('q')
elem.send_keys('pycon')
elem.send_keys(Keys.RETURN)
Run Code Online (Sandbox Code Playgroud)
不知道怎么解决这个问题?我搜索了一些类似的问题,但没有找到解决方案.如果有人可以提供一些信息,我会批评它.
OS:Ubuntu 16.04
Firefox:55
python:3.5
selenium:3.4
Run Code Online (Sandbox Code Playgroud)
问题解决了!谢谢你的帮助.
解决方案:确保127.0.0.1 localhost文件中有/etc/host
事实证明,我很久以前改变了文件的乐趣,忘了将它改回T_T.我添加之后127.0.0.1 localhost,一切都很好.
以下程序挂起,但是如果我取消注释,System.out.printf它将正常退出。我不知道为什么会这样。提前致谢。
public class MainClass{
public static class Node{
public Integer val;
Node() {
val = new Integer(0);
}
public void hang() {
int i = 0;
while(this.val != 1) {
// the program quit normally if I uncomment the following line
//System.out.printf("");
i++;
}
System.out.println(i);
System.out.println("quit");
}
private int func(int i) {
return i+1;
}
}
public static void main(String[] args) throws InterruptedException{
Node n = new Node();
Thread t = new Thread(new Runnable(){
@Override
public void run() …Run Code Online (Sandbox Code Playgroud)