对于Selenium中的pageLoadTimeout无法正常工作感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解seleniumpageobject,并且为您提供关于Android-Htt
对于Selenium中的pageLoadTimeout无法正常工作感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解selenium pageobject,并且为您提供关于Android-HttpURLConnection setReadTimeout无法正常工作、Android的ObjectAnimator.ofFloat无法正常工作、AWS Chime useToggleLocalMute()无法正常工作、c – Memset无法正常工作的宝贵知识。
本文目录一览:- Selenium中的pageLoadTimeout无法正常工作(selenium pageobject)
- Android-HttpURLConnection setReadTimeout无法正常工作
- Android的ObjectAnimator.ofFloat无法正常工作
- AWS Chime useToggleLocalMute()无法正常工作
- c – Memset无法正常工作
Selenium中的pageLoadTimeout无法正常工作(selenium pageobject)
我在Java中使用以下使用selenium的代码。我要添加4秒的pageLoadTimeout,但是,驱动程序将继续等待,直到整个页面加载完毕。有什么帮助吗?
System.setProperty("webdriver.gecko.driver", System.getProperty("user.home") + "\\Desktop\\geckodriver.exe"); FirefoxBinary b = new FirefoxBinary(new File(System.getProperty("user.home") + "\\desktop\\Mozilla Firefox\\firefox.exe")); FirefoxOptions options = new FirefoxOptions().setBinary(b); driver = new FirefoxDriver(options); //driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(4, TimeUnit.SECONDS); driver.get("https://www.booking.com/hotel/in/the-taj-mahal-palace-tower.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaGyIAQGYATG4AQbIAQzYAQHoAQH4AQKSAgF5qAID;sid=338ad58d8e83c71e6aa78c67a2996616;dest_id=-2092174;dest_type=city;dist=0;group_adults=2;hip_dst=1;hpos=1;room1=A%2CA;sb_price_type=total;srfid=ccd41231d2f37b82d695970f081412152a59586aX1;srpvid=c71751e539ea01ce;type=total;ucfs=1&#hotelTmpl"); List<WebElement> facilitySectionList = driver.findElements(By.className("facilitiesChecklistSection"));
答案1
小编典典解决该 pageLoadTimeout
问题的方法是将您的 Selenium
版本升级到 v3.5.0
。这是有效的代码块,并且使用 org.openqa.selenium.TimeoutException: Timeout loading pageafter 2000ms
最少的代码即可生成您自己的代码:
- 代码块:
public class Q45591282_pageloadtimeout { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe"); WebDriver driver=new FirefoxDriver(); driver.manage().timeouts().pageLoadTimeout(2, TimeUnit.SECONDS); driver.get("https://www.booking.com/hotel/in/the-taj-mahal-palace-tower.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaGyIAQGYATG4AQbIAQzYAQHoAQH4AQKSAgF5qAID;sid=338ad58d8e83c71e6aa78c67a2996616;dest_id=-2092174;dest_type=city;dist=0;group_adults=2;hip_dst=1;hpos=1;room1=A%2CA;sb_price_type=total;srfid=ccd41231d2f37b82d695970f081412152a59586aX1;srpvid=c71751e539ea01ce;type=total;ucfs=1&#hotelTmpl"); } }
- 控制台输出:
1502530864350 geckodriver INFO geckodriver 0.18.0 1502530864365 geckodriver INFO Listening on 127.0.0.1:29688 1502530865042 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe with args ["-marionette"] 1502530903170 Marionette INFO Listening on port 1900 Aug 12, 2017 3:11:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Exception in thread "main" org.openqa.selenium.TimeoutException: Timeout loading page after 2000ms Build info: version: ''3.5.0'', revision: ''8def36e068'', time: ''2017-08-10T23:00:22.093Z'' System info: host: ''ATECHM-03'', ip: ''192.168.1.48'', os.name: ''Windows 8'', os.arch: ''amd64'', os.version: ''6.2'', java.version: ''1.8.0_77'' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=C:\Users\ATECHM~1\AppData\Local\Temp\rust_mozprofile.LSsvaNqlDbxE, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=6.2, moz:processID=3652.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}] Session ID: 8b841376-00fd-4359-8cae-a68912b23706 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:368) at demo.Q45591282_pageloadtimeout.main(Q45591282_pageloadtimeout.java:20)
捕获WebDriverException
- 代码块:
public class pageLoadTimeout { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().timeouts().pageLoadTimeout(2, TimeUnit.SECONDS); try{ driver.get("https://www.booking.com/hotel/in/the-taj-mahal-palace-tower.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaGyIAQGYATG4AQbIAQzYAQHoAQH4AQKSAgF5qAID;sid=338ad58d8e83c71e6aa78c67a2996616;dest_id=-2092174;dest_type=city;dist=0;group_adults=2;hip_dst=1;hpos=1;room1=A%2CA;sb_price_type=total;srfid=ccd41231d2f37b82d695970f081412152a59586aX1;srpvid=c71751e539ea01ce;type=total;ucfs=1&#hotelTmpl"); }catch(WebDriverException e){ System.out.println("WebDriverException occured"); } driver.quit(); } }
- 控制台输出:
Only local connections are allowed. Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code. Jul 17, 2019 8:53:26 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C [1563377008.449][SEVERE]: Timed out receiving message from renderer: 1.999 [1563377008.450][SEVERE]: Timed out receiving message from renderer: -0.001 [1563377008.461][SEVERE]: Timed out receiving message from renderer: -0.012 [1563377010.466][SEVERE]: Timed out receiving message from renderer: 1.998 [1563377010.467][SEVERE]: Timed out receiving message from renderer: -0.001 [1563377010.476][SEVERE]: Timed out receiving message from renderer: -0.010 WebDriverException occured
Android-HttpURLConnection setReadTimeout无法正常工作
我正在开发一个需要从服务器下载数据的应用程序.
我使用以下代码,除了有时在文件下载过程中被卡住之外,该代码行得通.
try{
URL url = new URL( dlUrl );
con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(1000); // timeout 1 sec
con.setReadTimeout(1000); // timeout 1 sec
// get file length
int lenghtOfFile = con.getContentLength();
is = url.openStream();
String dir = Environment.getExternalStorageDirectory() + "myvideos";
File file = new File( dir );
if( !file.exists() ){
if( file.mkdir()){
// directory succesfully created
}
}
fos = new FileOutputStream(file + "/" + "video.mp4");
byte data[] = new byte[1024];
long total = 0;
while( (count = is.read(data)) != -1 ){
total += count;
publishProgress((int)((total*100)/lenghtOfFile));
fos.write(data, 0, count);
}
} catch (Exception e) {
Log.e(TAG, "DOWNLOAD ERROR = " + e.toString() );
}
finally{
// close streams
}
问题可能是我正在使用的WIFI连接不稳定,或者我的代码丢失了.
现在,我想在下载停止时添加解决方法,但是不幸的是setReadTimeout似乎没有效果!
我尝试了Stackoverflow中建议的解决方案,但没有一项对我有用.
我是否缺少某种设置?
有什么想法为什么setReadTimeout没有效果?
解决方法:
这是对已有多年历史的问题的新解答,但我的代码中有一个类似的问题可以解决.
这行是问题所在:
is = url.openStream();
获取输入流的正确方法是简单地从连接对象而不是url对象获取输入流.
is = con.getInputStream();
前一种方法可能会打开另一个与通过调用url.openConnection()获得的连接对象分离的网络连接.
我通过评估this web blog page找出了所有这些.
对于其他存在类似问题的人,在调用getInputStream或连接对象的connect方法之前,尽早调用setReadTimout也很重要.
Android的ObjectAnimator.ofFloat无法正常工作
MainActivity(扩展活动):
Button button1 = (Button) findViewById(R.id.button1); button1.setonClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startAnimation(); } }); public void startAnimation() { ImageView aniView = (ImageView) findViewById(R.id.imageView1); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(aniView,"alpha",0f); fadeOut.setDuration(2000); ObjectAnimator mover = ObjectAnimator.ofFloat(aniView,"translationX",-500f,0f); mover.setInterpolator(new TimeInterpolator() { @Override public float getInterpolation(float input) { Log.v("MainActivity","getInterpolation() " + String.format("%.4f",input)); return input; } }); mover.setDuration(2000); ObjectAnimator fadeIn = ObjectAnimator.ofFloat(aniView,0f,1f); fadeIn.setDuration(2000); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(mover).with(fadeIn).after(fadeOut); animatorSet.start(); }
三星galaxy S4(Android 4.4.2):
getInterpolation() 1,0000 getInterpolation() 1,0000
三星galaxy S5(Android 4.4.2):
getInterpolation() 0,0000 getInterpolation() 0,0085 getInterpolation() 0,0170 getInterpolation() 0,0255 ... ... getInterpolation() 0,9740 getInterpolation() 0,9825 getInterpolation() 0,9910 getInterpolation() 0,9995 getInterpolation() 1,0000
有人有一个想法,为什么这不能正常工作?
解决方法
AWS Chime useToggleLocalMute()无法正常工作
我可以模拟该问题,然后在互联网上搜索this post on github。
我尝试实施此处建议的内容,但对我不起作用,因此我决定使用const meetingManager = useMeetingManager();
通过使用该功能,我可以通过拨打电话来静音/取消静音
await meetingManager.audioVideo?.realtimeUnmuteLocalAudio();
await meetingManager.audioVideo?.realtimeMuteLocalAudio();
我不知道这是否是最好的解决方案,但这对我有用,直到他们按照github上的帖子更新文档为止。
c – Memset无法正常工作
#include <iostream> #include <cstring> using namespace std; int main() { int l[3][3]; memset (l,1,sizeof(l)); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cout << l[i][j] << " "; } cout << endl; } return 0; }
我希望使用该行将整个数组初始化为1:
memset(l,sizeof(l));
但我没有得到预期的值,它给了我以下输出:
16843009 16843009 16843009 16843009 16843009 16843009 16843009 16843009 16843009
认为这可能是编译器问题,所以我尝试使用Ideone:
http://ideone.com/VFYUDg
请帮忙.
解决方法
如果需要用数字填充二维C风格数组:
int l[3][3]; std::fill_n(*l,sizeof l / sizeof **l,1);
* l这里将int [3] [3]衰减成指向数组的第一个元素的指针(int *),sizeof l / sizeof ** l产生数组元素的数量.
它使用C要求,即数组在内存中连续布局,没有间隙,因此多维数组具有与单维数组相同的布局.例如. int [3] [3]具有与int [3 * 3]相同的布局.
而且,与memset不同,std :: fill_n在对象级别上运行,而不是在字节上运行.对于内置类型,优化版本通常作为SIMD指令内联,效率不低于memset.
今天关于Selenium中的pageLoadTimeout无法正常工作和selenium pageobject的介绍到此结束,谢谢您的阅读,有关Android-HttpURLConnection setReadTimeout无法正常工作、Android的ObjectAnimator.ofFloat无法正常工作、AWS Chime useToggleLocalMute()无法正常工作、c – Memset无法正常工作等更多相关知识的信息可以在本站进行查询。
本文标签: