我目前正在使用selenium webdriver来解析Facebook用户朋友页面并从AJAX脚本中提取所有ID.但我需要向下滚动才能吸引所有朋友.如何在Selenium中向下滚动.我正在使用python.
我目前是机器人框架的新手。我目前正在使用最新的 chrome 和 chromedriver 窗口版本,它是 80,但是当我尝试运行测试时,它给出消息“SessionNotCreatedException:消息:未创建会话:此版本的 ChromeDriver 仅支持 Chrome pycharm 中的版本 81”,但目前仅提供 81 的测试版。我试过卸载所有东西并重新安装它,但没有任何效果任何人都可以帮助我解决这个问题。谢谢!
selenium google-chrome robotframework selenium-chromedriver selenium-webdriver
我正在使用Selenium2对我的网站进行一些自动化测试,我希望能够获得一些Javascript代码的返回值.如果我foobar()在我的网页上有一个Javascript函数,并且我想调用它并将返回值放入我的Python代码中,我可以调用什么来做到这一点?
我正在研究Java Selenium-WebDriver.我补充道
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
和
WebElement textbox = driver.findElement(By.id("textbox"));
Run Code Online (Sandbox Code Playgroud)
因为我的应用程序需要几秒钟来加载用户界面.所以我设置2秒implicitwait.但我无法找到元素文本框
然后我补充说 Thread.sleep(2000);
现在它工作正常.哪一种更好?
我正在使用Selenium 2 Java API和FirefoxDriver.当我填写表单时,根据表单输入将复选框添加到页面.
我想使用Selenium模拟这些复选框的点击.该元素在常规浏览器中可见并可用,但selenium断言元素不可见.
"Element is not currently visible and so may not be interacted with"
Run Code Online (Sandbox Code Playgroud)
我可以强制硒忽略元素的不可见状态吗?如何强制Selenium与不可见元素进行交互?
这是如何实现的?在这里它说java版本是:
WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");
Run Code Online (Sandbox Code Playgroud)
但我找不到C#代码来做到这一点.
我正在将我的selenium 1代码转换为selenium 2,并且找不到任何简单的方法来在下拉菜单中选择标签或获取下拉列表的选定值.你知道如何在Selenium 2中做到这一点吗?
以下是两个在Selenium 1中有效但在2中不起作用的语句:
browser.select("//path_to_drop_down", "Value1");
browser.getSelectedValue("//path_to_drop_down");
Run Code Online (Sandbox Code Playgroud) 根据上一个问题,我将Selenium更新为2.0.1版但现在我有另一个错误,即使配置文件存在于/tmp/webdriver-py-profilecopy:
File "/home/sultan/Repository/Django/monitor/app/request.py", line 236, in perform
browser = Firefox(profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 46, in __init__
self.binary, timeout),
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 46, in __init__
self.binary.launch_browser(self.profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 87, in _wait_until_connectable
raise WebDriverException("Can't load the profile. Profile Dir : %s" % self.profile.path)
selenium.common.exceptions.WebDriverException: Can't load the profile. Profile Dir : /tmp/webdriver-py-profilecopy
怎么了?我该如何解决这个问题?
我有一个用Selenium测试的Web应用程序.页面加载时会运行很多JavaScript.
这段JavaScript代码编写得不是很好,但我无法改变任何东西.所以等待元素出现在DOM中的findElement()方法不是一种选择.
我想在Java中创建一个通用函数来等待页面加载,可能的解决方案是:
document.body.innerHTML在字符串变量中body.body变量与之前版本进行比较body.如果它们相同则设置增量计数器,notChangedCount否则设置notChangedCount为零.notChangedCount >= 10那么退出循环,否则循环到第一步.你认为这是一个有效的解决方案吗?
我设置了一个python代码来运行Selenium chromedriver.exe.在运行结束时,我必须browser.close()关闭实例.(browser = webdriver.Chrome())我相信它应该chromedriver.exe从内存中释放(我在Windows 7上).但是,每次运行后chromedriver.exe,内存中仍有一个实例.我希望有一种方法可以在python中编写一些东西来杀死chromedriver.exe进程.显然browser.close()不做这项工作.谢谢.