我是整个Robotframework和Selenium2Library的新手,我和我有一个问题。
我有两个div: rasterContainer和anlageContainer。它们的x和y偏移量是一样的。anlageContainer的z偏移量为3,rasterContainer为0.anlageContainer位于rasterContainer的顶部。这两个构建时间bar.The anlageContainer只获得一个id,而rasterContainer包含许多其他div,每个div都带有一个id。如果鼠标移动到这些div上,rasterContainer就会显示时间。如果单击那里,只需单击anlageContainer和其他一些方法,计算偏移量以获得时间,然后在文本框中打开一个窗口。
我想做的是:
我希望将鼠标移动到rasterContainer的一个元素,并在anlageContainer上的相同位置单击。
我试过的是:
我开始用python写我自己的图书馆。我只有一个获得Selenium2Library实例的方法,鼠标位置的垂直值(鼠标位于anlageContainer的顶部)和光栅容器元素的垂直值。
def click_on_element(self, vertEl, vertMo, se2lib):
v = vertEl - vertMo
#Get Webdriver
driver = se2lib._current_browser()
#ActionChains instance
ac = webdriver.ActionChains(driver)
ac.move_by_offset(0, v)
ac.click().perform()
return "On my way"使用move_by_offset:打开窗口,但打开的时间不对(07:00)。我想要09:30。
我也试过:
#Get Element
elmfinder = ElementFinder()
elm = elmfinder.find(driver, "5_09_30")[0]
ac.move_to_element(elm)
ac.move_to_element_with_offset(elm, 461, 422)窗户既没有用move_to_element打开,也没有用move_to_element_with_offset.打开
我真的不知道我在这里错过了什么。
任何暗示都会有帮助。
编辑: HTML代码:
<div id="resource_id_5_2013-07-30" class="resource" daylenght="720" loaded="false" date="2013-07-30" time="07:00" style="top: 0px; height: 1540px; width: 309.75px; left: 619.5px;">
<div class="terminContainer"></div>
<div class="overlapContainer" style="width: 10%; position: absolute; left: 90%; height: 1560.0px; top: 0px;"></div>
<div id="5" class="anlageContainer" style="width: 10%; height: 1440px; top: 0px;" title="08:53"></div>
<div class="rasterContainer" style="width: 10%; height: 1440px; top: 0px;">
<div id="5_07_00" class="rasterLabel" style="position: absolute; top: 0px;">7:00</div>
<div id="5_07_15" class="rasterLabel" style="position: absolute; top: 30px;">7:15</div>
<div id="5_07_30" class="rasterLabel" style="position: absolute; top: 60px;">7:30</div>
etc...
</div>
</div>CSS样式:
.rasterContainer{
position: absolute;
background-color: #EEEEEE;
}
.anlageContainer:hover + .rasterContainer{
background-color: #e3e3e3;
}
.rasterLabel{
z-index: 2;
font-size: 0.7em;
color: #000;
border-top: solid 1px #888;
}
.anlageContainer{
z-index: 3;
cursor: pointer;
position: absolute;
}在这里,您可以看到anlageContainer位于rasterContainer之上。它们之间是rasterLabels ->z-索引.
anlageContainer有
dojo.connect(anlageContainer, 'onclick', function(clickevt){
addTermin(resourceId, getOffsetY(clickevt)/g_terminMultiplikator, datum);
});与图像的两个链接:
时间条
三维时间条
发布于 2013-07-28 15:00:51
element = find_element_by_xpath (driver, ".//div[@id='resource_id_5_2013-07-30']//div[@class='anlageContainer']")
element.click()https://stackoverflow.com/questions/17804506
复制相似问题