from selenium import webdriver
driver=webdriver.Firefox()
driver.get(url)
Run Code Online (Sandbox Code Playgroud)
有时,网络驱动程序卡在文件或响应上,并且页面从未完全加载,因此该行
driver.get(url)
Run Code Online (Sandbox Code Playgroud)
永远不会完成。但我已经获得了足够的源代码来运行其余的代码。我想知道如果页面在 10 秒内没有完全加载,我该如何绕过或刷新页面。
我努力了
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
driver=webdriver.Firefox()
driver.set_page_load_timeout(10)
while True:
try:
driver.get(url)
except TimeoutException:
print("Timeout, retrying...")
continue
else:
break
Run Code Online (Sandbox Code Playgroud)
但这条线
driver.set_page_load_timeout(10)
Run Code Online (Sandbox Code Playgroud)
总是给我以下错误
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 727, in set_page_load_timeout
'pageLoad': int(float(time_to_wait) * 1000)})
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message:
Run Code Online (Sandbox Code Playgroud)
Message: 之后就什么都没有了。我无法识别错误的类型。奇怪的是我的笔记本电脑无法运行
driver.set_page_load_timeout(10)
Run Code Online (Sandbox Code Playgroud)
我的下一步是单击页面上的按钮,但即使在完全加载后,该按钮也并不总是存在。因此我不能使用显式等待。
谢谢
我的角度应用程序中有多个延迟加载的模块,其中尝试使用子路由,但在页面重新加载/刷新时不起作用
在单击功能上工作正常,导航到预期组件,但在页面刷新时它不适用于 localhost:4200/port-move/overview。
localhost:4200/overview - 这适用于刷新。可以将其更正为方法 - > localhost:4200/port-move/overview 。有人可以帮忙吗
主 Rouitng 模块 (app-routing.module.ts) 中的路由:
const routes: Routes = [
{ path: '', redirectTo: 'search-uploads', pathMatch: 'full' },
{ path: 'port-move', loadChildren: () => import('./modules/routes/port-move/port-move.module').then(mod => mod.PortMoveModule) },
{ path: 'change-card', loadChildren: './modules/routes/change-card/change-card.module#ChangeCardModule' },
{ path: 'search-uploads', loadChildren: './modules/routes/search-uploads/search-uploads.module#SearchUploadsModule' },
{ path: 'inventory-recovery', loadChildren: './modules/routes/inventory-recovery/inventory-recovery.module#InventoryRecoveryModule' }
];
Run Code Online (Sandbox Code Playgroud)
Port-move/(惰性模块之一)中的路由:
const routes: Routes = [
{ path: '', component: PortMoveComponent },
{ path: 'overview', component: PortMoveOverviewComponent }
]
Run Code Online (Sandbox Code Playgroud)
单击功能导航到 Port-move-overview 组件,其中 port-move …
我有一个测试 django 应用程序。
在一页中,测试向所有用户显示相同的问题。
我希望当用户正确回答时,向其他活动用户的浏览器发送信号以刷新下一个问题。
我一直在学习 django 中的信号,我正在学习使用它们,但我现在不知道如何将“刷新信号”发送到客户端浏览器。
我认为它可以使用 javascript 代码来检查某个值(实际问题)是否更改,如果更改会重新加载页面,但我不知道这种语言,而且我发现的信息很混乱。
有谁能够帮助我?
非常感谢。
我正在使用付费角色系统,一旦用户刷新浏览器,我需要刷新该页面中可用的统计数据(统计数据应该来自数据库并显示).但是现在它无法正常工作,在页面刷新中,不会调用java代码,而是使用以前的数据加载缓存页面.我尝试修复它添加下面的代码,但它没有工作.
@Override
protected void setHeaders(WebResponse response) {
response.setHeader("Cache-Control",
"no-cache, max-age=0,must-revalidate, no-store");
}
Run Code Online (Sandbox Code Playgroud)
有谁知道修复此问题?谢谢!
这是最初的代码
ManageCredits.html
<wicket:head>
<wicket:link>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
</wicket:link>
</wicket:head>
<wicket:panel xmlns:wicket="http://wicket.apache.org/">
<div class="offercount-container round-border">
<div class="manage-credits-lbl"><span>Manage Credits</span></div>
<div>
<ul>
<li>Balance amout:<span wicket:id="balanceAmtLbl" >0</span></li>
<li>Number if transactions<span wicket:id="transactionLbl" >0</span></li>
</ul>
</div>
</div>
</wicket:panel>
Run Code Online (Sandbox Code Playgroud)
ManageCredits.java
import com.payrole.service.Offer;
import com.payrole.service.OfferService;
import com.payrole.service.ServiceLocator;
import com.payrole.wicket.PayroleLabel;
import java.text.Format;`enter code here`
import org.apache.wicket.markup.html.panel.Panel;
public class OfferFanSummaryPanel extends Panel{
private long balance;
private long transactionCount;
public OfferFanSummaryPanel(String id){
super(id);
}
public OfferFanSummaryPanel(String id, …Run Code Online (Sandbox Code Playgroud) 我在stackoverflow中搜索了这个问题并且看到了类似的问题(但不完全是我正在寻找的),但解决方案似乎不起作用.我只是jQuery的新手,我需要你的帮助才能做到这一点.(交叉手指)
所以我有一个带有按钮的网页(例如,parentPage.html).单击该按钮(执行openItemPopup函数)时,它将使用jQuery UI打开模式对话框.模态对话框"#contentWindow"的内容是一个不同的页面(例如modalDialog.html).
function resetContent() {
$('#contentFrame').attr('src', '/images/ajax-loader.gif');
}
function closeContent() {
$('.ui-dialog-titlebar-close').click();
}
function openItemPopup(){
$('#contentWindow').dialog({width:980, modal: true,
close: function(ev, ui) { resetContent(); }
});
}
Run Code Online (Sandbox Code Playgroud)
在modalDialog.html中,当单击一个锚点时,它会执行一些逻辑,并且需要动态关闭模态对话框.有人告诉我使用它,这已经有效了:
// refresh parent page before closing
// doesn't work
location.reload(true);
// close the modal dialog
window.top.closeContent();
return false;
window.location='javascript:void();';
Run Code Online (Sandbox Code Playgroud)
我的问题是:我需要在关闭模式对话框之前刷新parentPage.html.您在上面看到我尝试使用location.reload(true);,但它重新加载模式对话框而不是parentPage.html.我无法发布图片,但它说*"无效的Web应用程序会话".*
我也试过了window.top.location.reload(); 它似乎工作.它重新加载parentPage.html并关闭模式对话框.
// refresh parent page before closing
// seems working but has error
window.top.location.reload();
// close the modal dialog
window.top.closeContent();
return false;
window.location='javascript:void();';
Run Code Online (Sandbox Code Playgroud)
但是,它说"无效的Web应用程序会话". - 就像使用location.reload(true);时一样.我不知道为什么会这样,以及如何解决它.我甚至不确定window.top.location.reload是否是正确的方法.
仅供参考:我正在尝试刷新parentPage.html以便能够从模态对话框中获取数据.之前,modalDialog.html曾用作简单的html页面.列表和字段等数据从modalDialog.html正确返回到parentPage.html.他们想将其转换为模态对话框以防止大量页面刷新.有人告诉我,可以使用AJAX,但这是很多工作.此外,我不是主人.如果您有更好的建议,请随时告诉我! …
今天遇到socket.io的问题.当我刷新页面时.on("connect",{})永远不会触发.当我从网址加载页面时,所有事件都会按照应有的方式启动.如下所示,我将gameStatus设置为已损坏.在一系列客户端/服务器通信之后,游戏状态应更新为"就绪",并且应在服务器上创建新的播放器.当我重新加载页面(cmd + r)时,没有任何客户端事件触发.
服务器端识别新连接"看到"新的socket.id并发出"发送房间"事件,但是在客户端没有收到该事件.
我试图强制新连接,但我不知道我是否正确使用它.
上周这按照我的预期工作,然后今天甚至没有更新代码,它无法在页面刷新时触发这些事件.如果我从完整的URL加载页面(http://localhost:3000在这种情况下),一切正常
index.html的:
var io = io.connect('/', {'force new connection': true});
Run Code Online (Sandbox Code Playgroud)
client.js
var gameStatus = 'broken';
var localPlayer;
window.onload = function() {
console.log(gameStatus); // "broken"
io.on("connect", onSocketConnected);
io.on("disconnect", onSocketDisconnect);
io.on("new player", onNewPlayer);
io.on("send room", function(data){
console.log("send room fired"); // doesn't fire on refresh
addPlayer(data);
});
}
function onSocketConnected() {
console.log("Connected to socket server "); // doesn't connect on refresh
// assign socket.sessionid as the player name
localPlayer.id = io.socket.sessionid;
io.emit("new player", {id: localPlayer.id});
console.log(localPlayer.id); …Run Code Online (Sandbox Code Playgroud) 我使用了两个UpdatePanel标签,一个有一个Svginside 并且我需要在单击按钮时刷新其内容,而该按钮在另一个UpdatePanel. 我只是意识到Page_Load每次单击按钮时都会执行代码隐藏中的函数。我UpdateMode="Conditional"已经设置了属性但没有帮助。知道为什么吗?以下是我的代码:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" id="GlobalUpdatePanel" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="ButtonPP" eventname="Click" />
</Triggers>
<ContentTemplate>
<svg width ="1024" height = "540"></svg>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="ControlUpdatePanel" runat="server" Visible="True" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button id ="ButtonPP" runat="server" Text="Run PP" OnClick="ButtonPP_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
有什么方法可以强制浏览器仅刷新(重新下载)JS资源,而不刷新整个页面?任何Web浏览器中的解决方案都可以。当然,与浏览器无关的解决方案将是最好的。
背景:我们的应用程序在同一页面上有多个屏幕。在一个屏幕上执行一些操作后,AJAX将获取另一个屏幕。由于页面上经常使用JS,因此我经常需要更改其JS资源。在刷新页面以获取固定的JS之后,必须先浏览所有先前的屏幕,然后才能转到当前正在调试的屏幕。
我有以下代码片段
import { Component, OnInit } from "@angular/core";
import { AuthenticationService } from "../shared/services/authentication.service";
import { User } from "./user";
import { UserService } from "./user.service";
@Component({
templateUrl:'./user.component.html'
})
export class UserComponent implements OnInit{
user: User;
constructor(
private _userService: UserService,
private _authService:AuthenticationService){
}
ngOnInit(){
let user = this._userService.getUser();
if(!user){
this._authService.getLoggedUser().subscribe(
user => {
this.user = user;
this._userService.setLoggedUser(user);
}
);
this._userService._loggedUser$.subscribe(
user => {
this.user = user;
}
)
}else{
this.user = user;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这在第一条路由初始化(/user/profile)与else块的情况下工作正常。但是当用户刷新浏览器窗口时,我再次向服务器发出请求并让用户返回并呈现我的 …
我注意到,当我刷新应用程序上的页面时,如果我通过了身份验证,它会跳到登录页面,然后转到仪表板。不管我刷新哪个页面。
我对反应还很陌生,但我认为问题出在我的 PrivateRoute.js 逻辑中。它会“否则:重定向到登录”,但不会在登录页面上失败,因此它遵循“如果经过身份验证则重定向到仪表板”路线。
应用程序.js:
import React, { Component, Fragment } from "react";
import ReactDOM from "react-dom";
import {
HashRouter as Router,
Route,
Switch,
Redirect
} from "react-router-dom";
import { Provider as AlertProvider } from "react-alert";
import AlertTemplate from "react-alert-template-basic";
import Header from "./layout/Header";
import Sidebar from "./layout/Sidebar";
import Home from "./common/Home";
import Profile from "./accounts/profile";
import Dashboard from "./leads/Dashboard";
import Alerts from "./layout/Alerts";
import Login from "./accounts/Login";
import Register from "./accounts/Register";
import PrivateRoute from "./common/PrivateRoute";
import { Provider } …Run Code Online (Sandbox Code Playgroud) page-refresh ×10
javascript ×2
angular ×1
angular8 ×1
asp.net ×1
buttonclick ×1
django ×1
java ×1
jquery ×1
lazy-loading ×1
node.js ×1
python ×1
react-redux ×1
reactjs ×1
redux ×1
routes ×1
selenium ×1
socket.io ×1
sockets ×1
updatepanel ×1
wicket ×1