我对Selenium来说是全新的.我想在以下代码中执行javascript代码段(如代码中所述),但不能这样做.请帮忙.
from selenium import webdriver
import selenium
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
patch = raw_input("Enter patch number\n")
rel = raw_input("Enter release\n")
plat = raw_input("Enter port\n")
browser = webdriver.Firefox()
browser.get("xxxxxxxxxxxxxxxxx")
pdtfamily = browser.find_element_by_id("prodFamilyID")
pdtfamily.send_keys("Database & Tools" + Keys.TAB)
time.sleep(5)
pdt = browser.find_element_by_id("productID")
pdt.send_keys("Intelligent Agent" + Keys.TAB)
time.sleep(5)
pdt1 = browser.find_element_by_id("patchCacheChkBxID")
pdt1.send_keys(Keys.SPACE)
time.sleep(5)
pdt7 = browser.find_element_by_id("M__Idf")
pdt7.send_keys(plat)
pdt8 = browser.find_element_by_id("M__Idg")
pdt8.send_keys("American English")
# Here I want to execute this javascript - "submitForm('patchCacheAdd',1,{'event':'ok'});return false"
browser.close()
Run Code Online (Sandbox Code Playgroud)
如果我使用 -
selenium.GetEval("submitForm('patchCacheAdd',1,{'event':'ok'});return …Run Code Online (Sandbox Code Playgroud) 目前ulimit -n显示10000.我想把它增加到40000.我编辑了"/etc/sysctl.conf"并放了fs.file-max=40000.我还编辑/etc/security/limits.conf并更新了硬和软值.但仍然是ulimit节目10000.完成所有这些更改后,我重新启动了笔记本电脑.我可以访问root密码.
usr_name@usr_name-lap:/etc$ /sbin/sysctl fs.file-max
fs.file-max = 500000
Run Code Online (Sandbox Code Playgroud)
添加以下行/etc/security/limits.conf-
* soft nofile 40000
* hard nofile 40000
Run Code Online (Sandbox Code Playgroud)
我还添加了以下内容/etc/pam.d/su-
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
我已经尝试过在其他论坛上提供的所有可能的方式,但我可以达到最大限度,但10000不能超过这个限制.可能是什么问题?
我正在进行此更改,因为neo4j抛出最大打开文件限制达到错误.
我通过下载http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49在Windows上安装了pip 并运行python setup.py install
安装顺利,没有错误.
但是当我尝试用它安装selenium包时,它给了我以下错误 -
pip install -U selenium
Unknown option: u
Unknown or unsupported command 'install'
Run Code Online (Sandbox Code Playgroud)
我在哪里弄错了?
我有一个EC2节点,node1(安全组SG1),它应该可以从端口9200上的另一个EC2节点node2(安全组SG2)访问.现在,当我在SG1中添加一个带有端口9200的入站规则并指定SG2作为源自定义IP部分,我无法从node2访问node1.另一方面,如果我在SG1中指定入站规则,其源为0.0.0.0/0或节点2的IP,则它可以正常工作.我的做法有什么问题?
我正在使用pandas/python数据帧.我想做一个滞后减法.
我目前正在使用:
newCol = df.col - df.col.shift()
Run Code Online (Sandbox Code Playgroud)
这导致第一点出现NaN:
NaN
45
63
23
...
Run Code Online (Sandbox Code Playgroud)
第一个问题:这是这样做减法的最好方法吗?
第二:如果我想向这个新列添加一列(相同的行数).有没有办法可以让所有NaN的0用于计算?
例如:
col_1 =
Nan
45
63
23
col_2 =
10
10
10
10
new_col =
10
55
73
33
Run Code Online (Sandbox Code Playgroud)
并不是
NaN
55
73
33
Run Code Online (Sandbox Code Playgroud)
谢谢.
for i in driver.find_elements_by_class_name("endorse-count"):
try:
i.click()
except:
continue
elem = WebDriverWait(driver, 100).until(EC.presence_of_element_located((By.CLASS_NAME, "dialog-window")))
src = elem.get_attribute("innerHTML")
add_skill(name, src)
WebDriverWait(driver, timeout=10)
Run Code Online (Sandbox Code Playgroud)
运行上面的代码时出现以下错误 -
selenium.common.exceptions.StaleElementReferenceException: Message: u'Element is no longer attached to the DOM' ; Stacktrace:
at fxdriver.cache.getElementAt (resource://fxdriver/modules/web_element_cache.js:7646)
Run Code Online (Sandbox Code Playgroud)
换行 -
src = elem.get_attribute("innerHTML")
Run Code Online (Sandbox Code Playgroud)
登录后,我在LinkedIn用户个人资料页面上运行此代码.
我尝试在"i.click()"之后添加以下代码行 -
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
但后来我看到函数"add_skill(name,src)"没有被调用,并且没有调用driver.manage()之后的代码,尽管for循环和i.click()工作正常.
我正在使用lineinfile如下:
lineinfile dest=./hosts_exp insertafter='\[hosts1\]' line="xxxxxxxxx" state=present
Run Code Online (Sandbox Code Playgroud)
我的hosts_exp情况如下:
[local]
localhost
[hosts1]
[hosts2]
[hosts3]
Run Code Online (Sandbox Code Playgroud)
lineinfile在[hosts3]之后插入文本,而不是在[hosts1]之后插入它.
我正在尝试使用GridSearch进行LinearSVC()的参数估计,如下所示 -
clf_SVM = LinearSVC()
params = {
'C': [0.5, 1.0, 1.5],
'tol': [1e-3, 1e-4, 1e-5],
'multi_class': ['ovr', 'crammer_singer'],
}
gs = GridSearchCV(clf_SVM, params, cv=5, scoring='roc_auc')
gs.fit(corpus1, y)
Run Code Online (Sandbox Code Playgroud)
corpus1有形状(1726,7001),y有形状(1726,)
这是一个多类分类,y的值为0到3,包括两个值,即有四个类.
但这给了我以下错误 -
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-220-0c627bda0543> in <module>()
5 }
6 gs = GridSearchCV(clf_SVM, params, cv=5, scoring='roc_auc')
----> 7 gs.fit(corpus1, y)
/usr/local/lib/python2.7/dist-packages/sklearn/grid_search.pyc in fit(self, X, y)
594
595 """
--> 596 return self._fit(X, y, ParameterGrid(self.param_grid))
597
598
/usr/local/lib/python2.7/dist-packages/sklearn/grid_search.pyc in _fit(self, X, y, parameter_iterable)
376 train, test, …Run Code Online (Sandbox Code Playgroud) 我正在使用Python的telnetlib telnet到某台机器并执行一些命令,我想得到这些命令的输出.
那么,目前的情况是什么 -
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("command1")
tn.write("command2")
tn.write("command3")
tn.write("command4")
tn.write("exit\n")
sess_op = tn.read_all()
print sess_op
#here I get the whole output
Run Code Online (Sandbox Code Playgroud)
现在,我可以在sess_op中获得所有合并输出.
但是,我想要的是在执行command1之后立即获取command1的输出,就像我在其他机器的shell中工作一样,如下所示 -
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("command1")
#here I want to get the output for command1
tn.write("command2")
#here I want to get the output for command2
tn.write("command3")
tn.write("command4")
tn.write("exit\n")
sess_op = tn.read_all()
print …Run Code Online (Sandbox Code Playgroud) 我正在尝试重命名扩展xyz[n]名为扩展名的多个文件xyz
例如:
mv *.xyz[1] to *.xyz
Run Code Online (Sandbox Code Playgroud)
但错误来了 - " *.xyz No such file or directory"