现在我的脚本转到页面并从下拉列表中打开第二个对象"Vijesti",然后才收到错误消息.
这是错误:
StaleElementReferenceException:消息:在缓存中找不到元素 - 可能是页面在查找后已更改
来自Selenium网站:
当对元素的引用现在"陈旧"时抛出.陈旧意味着该元素不再出现在页面的DOM上.StaleElementReferenceException的可能原因包括但不限于:
- 您不再位于同一页面上,或者自元素找到后页面可能已刷新.
- 该元素可能已被删除并重新添加到屏幕上,因为它已找到.例如重新定位的元素.当更新值并重建节点时,通常可以使用javascript框架进行此操作.
- 元素可能位于iframe或其他已刷新的上下文中.
我想要选择每个对象,然后打开它.
这是来自url的SELECT部分:
<select id="kategorija" name="kategorija">
<option value="0">Kategorija</option>
<option value="12">Vijesti</option>
<option value="8">Biznis</option>
<option value="5">Sport</option>
<option value="2">Magazin</option>
<option value="7">Lifestyle</option>
<option value="3">Scitech</option>
<option value="6">Auto</option>
</select>
Run Code Online (Sandbox Code Playgroud)
码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import time
driver = webdriver.Firefox()
driver.get("http://www.klix.ba/")
assert "Klix" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("test")
elem.send_keys(Keys.RETURN)
select = Select(driver.find_element_by_name('kategorija'))
all_options = [o.get_attribute('value') for o in select.options]
for x in all_options:
select.select_by_value(x)
time.sleep(3)
Run Code Online (Sandbox Code Playgroud)
这是我做测试的网址.
我正在尝试在我的本地Ubuntu机器上按照以下指南安装elasticsearch:
https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
,当尝试运行'./elasticsearch'时,出现以下错误:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: <br>
os::commit_memory(0x00007f0e50cc0000, 64075595776, 0) failed; <br>
error='Cannot allocate memory' (errno=12) <br>
There is insufficient memory for the Java Runtime Environment to continue.<br>
Native memory allocation (mmap) failed to map 64075595776 bytes for committing reserved memory
Run Code Online (Sandbox Code Playgroud)
这是内存统计:
total used free shared buffers cached
Mem: 8113208 4104900 4008308 44244 318076 1926964
-/+ buffers/cache: 1859860 6253348
Swap: 7812092 0 7812092
Run Code Online (Sandbox Code Playgroud)
来自日志的错误消息:
There is insufficient memory for the Java Runtime Environment to …Run Code Online (Sandbox Code Playgroud)