是一个允许您观看视频和其他内容的脚本。
单击鼠标后,使用python和selenium无法运行脚本。目前我正在使用此代码:videoGemPath = ".//*[@id='brandconnect']/a/img"
scriptPath = ".//*[@id='content']/script"
elementScript = "/html/body/div[2]/div[1]"
location = driver.find_element_by_xpath(scriptPath)
ActionChains(driver).move_to_element(location).click().perform()
但它会返回此错误
=============================================== ========================== Traceback(最近一次调用最后一次): 文件" C:\ Users \ xxxxxx \ Desktop \ Proggetti VB \ Per Web \ PythonApplication4 \ PythonApplication4 \ PythonApplication4.py",第66行,在test_Login中 ActionChains(司机).move_to_element(位置)。点击()。执行() 文件" C:\ Python27 \ lib \ site-packages \ selenium-2.48.0-py2.7.egg \ selenium \ webdriver \ common \ action_chains.py",第72行,执行 行动() 文件" C:\ Python27 \ lib \ site-packages \ selenium-2.48.0-py2.7.egg \ selenium \ webdriver \ common \ action_chains.py",第217行,in self._driver.execute(Command.MOVE_TO,{' element':to_element.id})) 文件" C:\ Python27 \ lib \ site-packages \ selenium-2.48.0-py2.7.egg \ selenium \ webdriver \ remote \ webdriver.py",第201行,执行 self.error_handler.check_response(响应) 文件" C:\ Python27 \ lib \ site-packages \ selenium-2.48.0-py2.7.egg \ selenium \ webdriver \ remote \ errorhandler.py",第181行,在check_response中 提出exception_class(消息,屏幕,堆栈跟踪) MoveTargetOutOfBoundsException:消息:元素内的偏移量无法滚动到视图中:(352.5,241.5):[object HTMLScriptElement] 堆栈跟踪: 在FirefoxDriver.prototype.mouseMoveTo(file:/// c:/users/xxxxxx/appdata/local/temp/tmpgnvb0k/extensions/fxdriver@googlecode.com/components/driver-component.js:10961) 在DelayedCommand.prototype.executeInternal_ / h(file:/// c:/users/xxxxxx/appdata/local/temp/tmpgnvb0k/extensions/fxdriver@googlecode.com/components/command-processor.js:12534) 在DelayedCommand.prototype.executeInternal_(file:/// c:/users/xxxxxx/appdata/local/temp/tmpgnvb0k/extensions/fxdriver@googlecode.com/components/command-processor.js:12539) 在DelayedCommand.prototype.execute /< (文件:/// C:/users/xxxxxxx/appdata/local/temp/tmpgnvb0k/extensions/fxdriver@googlecode.com/components/command-processor.js:12481)
=============================================== ==========================
脚本代码是这样的:
// create button
document.write('<div id="brandconnect"><a href="javascript:SSA_CORE.BrandConnect.engage();" onmouseover="hoverBC();" onmouseout="unhoverBC();"><img src="img/bconnect_area.png" class="tooltip" rel="Guarda video e ricevi Gemme gratis!" alt="" /></a></div>');
// ini local storage to save last button state if this html5 feature is available
var storage = false;
try {
if( window && window.localStorage ) {
storage = window.localStorage;
if( typeof(storage.bcVisible) === 'string' ) {
if( storage.bcVisible == 'true' ) {
showBC();
}
else {
hideBC();
}
}
}
}
catch( ignore ) {
// local storage might require user approval. in this case we don't use it
}
// handle button visibility
function handleBC(obj) {
if( typeof(obj) != 'object' || obj.length < 1 ) {
// no videos available
hideBC();
}
else {
// videos are available
showBC();
}
}
// show brandconnect button
function showBC() {
clink = document.getElementById('brandconnect');
if( clink ) {
clink.style.display = 'block';
}
if( storage ) {
storage.bcVisible = 'true';
}
}
// hide brandconnect button
function hideBC() {
document.getElementById('brandconnect').style.display = 'none';
if( storage ) {
storage.bcVisible = 'false';
}
}
function hoverBC() {
document.getElementById('brandconnect').style.backgroundPosition = '-89px 0';
}
function unhoverBC() {
document.getElementById('brandconnect').style.backgroundPosition = '0 0';
}
// definitions by JSON
var ssa_json = {
'applicationUserId': '512000516',
'applicationKey': '2ae25b1d',
'currencyName': 'Gemme',
'onCampaignsReady': handleBC,
'onCampaignsDone': hideBC,
'onCampaignCompleted': handleBC,
'onCampaignClose': handleBC
};
// embed supersonic script
(function(d,t){
var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = true;
g.src = ('https:' != location.protocol ? 'http://jsd.supersonicads.com' :
'https://supersonicads.cotssl.net') + '/inlineDelivery/delivery.min.gz.js';
s.parentNode.insertBefore(g,s);
}(document,'script'));
//]]>
我该如何解决?