webdriver

selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python

﹥>﹥吖頭↗ 提交于 2020-03-07 08:07:14
问题 I'm writing some code using Selenium, and at one point I make 7 requests, all to different websites. For the first one, this works fine. However, for others, I get a session ID error. I think that my browser is configured correctly, as I do get results from the first website. I have tried to put a WebDriverWait in between the requests, but to no avail. I think the websites might be blocking my requests. Does anyone have any idea how to solve this problem? I'm sorry if this is something stupid

selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python

南楼画角 提交于 2020-03-07 08:07:06
问题 I'm writing some code using Selenium, and at one point I make 7 requests, all to different websites. For the first one, this works fine. However, for others, I get a session ID error. I think that my browser is configured correctly, as I do get results from the first website. I have tried to put a WebDriverWait in between the requests, but to no avail. I think the websites might be blocking my requests. Does anyone have any idea how to solve this problem? I'm sorry if this is something stupid

层级定位

戏子无情 提交于 2020-03-06 22:21:30
网页代码: <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title>Level Locate</title> <script type="text/javascript" async="" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" /> </head> <body> <h3>Level locate</h3> <div class="span3"> <div class="well"> <div class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Link1</a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" id="dropdown1

第 4 章 WebDriver API - 4.2 控制浏览器 - Selenium3 自动化测试

一曲冷凌霜 提交于 2020-03-06 10:03:04
4.2 控制浏览器 WebDriver 主要提供操作页面上各种元素的方法 ,同时 ,它还提供了操作浏览器的一些方法 ,如控制浏览器窗口大小 、操作浏览器前进或后退等 。 4.2.1 控制浏览器窗口大小 有时候我们希望浏览器能在某种尺寸下运行。例如,可以将 Web 浏览器窗口设置成移动端大小(480x800),然后访问移动站点。WebDriver 提供的 set_window_size()方法可以用来设置浏览器窗口大小。 更多情况下,我们希望 Web 浏览器在全屏幕模式下运行,以便显示更多的元素,可以使用 maximize_window()方法实现,该方法不需要参数。 4.2.2 控制浏览器后退、前进 浏览器提供了后退和前进按钮,可以方便地在浏览过的网页之间切换,WebDriver 还提供了对应的 back()和 forward()方法来模拟后退和前进按钮。下面通过例子演示这两个方法的使用。 为了看清楚脚本的执行过程,这里每操作一步都通过 print()打印当前的 URL 地址。 4.2.3 模拟浏览器刷新 有时候需要手动刷新(按「F5」键)Web 页面,可以通过 refresh()方法实现。 4.3 WebDriver 中的常用方法 前面我们学习了定位元素的方法,但定位只是第一步,定位之后还需要对这个元素进行操作,比如,单击(按钮)或输入(输入框)。 (1)clear():清除文本

第 4 章 WebDriver API - Selenium3 自动化测试

寵の児 提交于 2020-03-05 09:41:29
第 4 章 WebDriver API 从本章开始正式学习 WebDriver API ,它可用来操作浏览器元素的一些类和方法 。 4.1 从定位元素开始 例如百度的首页,页面上有输入框、按钮、文字链接、图片等元素。自动化测试要做的就是模拟鼠标和键盘来操作这些元素,如单击、输入、鼠标悬停等。 而操作这些元素的前提是要定位它们。自动化工具,如何定位这些元素呢? 通过浏览器自带的(F12)开发者工具可以看到,页面元素都是由 HTML 代码组成的,它们之间有层级地组织起来,每个元素有不同的标签名和属性值。WebDriver 就是根据这些信息来定位元素的。 WebDriver 提供了 8 种元素定位方法,在 Python 中,对应的方法如下: ● id 定位 → find_element_by_id() ● name 定位 → find_element_by_name() ● tag 定位 → find_element_by_tag_name() ● class 定位 → find_element_by_class_name() ● link_text → find_element_by_link_text() ● partial link 定位 → find_element_by_partial_link_text() ● XPath 定位 → find_element_by_xpath

Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)

给你一囗甜甜゛ 提交于 2020-03-05 06:45:45
问题 I develop the selenium code that: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.edge.EdgeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.Select; import java.util.List; public class TestDemoQA { public static void main(String[] args) throws InterruptedException{ System.setProperty("webdriver.edge.driver", "C:\

Element doesn't exist although it has ID attribute

不打扰是莪最后的温柔 提交于 2020-03-05 06:12:41
问题 In selenium excel vba I am trying to learn more about how to deal with the CSS selectors And I am wondering because when inspecting an element with ID and when run the code I got a message that the element not found Here's the code till now Private bot As New selenium.ChromeDriver Sub Test() Dim win, mainWin As selenium.Window, sCode As String, i As Long Dim urlImage As String, urlPost As String Dim sCase As String sCase = "192160470" Set bot = New ChromeDriver With bot .Start "Chrome" 'First

Element doesn't exist although it has ID attribute

ぃ、小莉子 提交于 2020-03-05 06:11:25
问题 In selenium excel vba I am trying to learn more about how to deal with the CSS selectors And I am wondering because when inspecting an element with ID and when run the code I got a message that the element not found Here's the code till now Private bot As New selenium.ChromeDriver Sub Test() Dim win, mainWin As selenium.Window, sCode As String, i As Long Dim urlImage As String, urlPost As String Dim sCase As String sCase = "192160470" Set bot = New ChromeDriver With bot .Start "Chrome" 'First

How to click on a link with trailing white-space characters on a web page?

江枫思渺然 提交于 2020-03-05 03:22:32
问题 There are links like this on a web page: Overview General Settings AR Server Settings Cache Settings Report Settings Web Service Settings Log Settings Change Password I am writing an automation script in selenium under Java eclipse and want to click on Cache Settings option. Can some one help? I know this would be simple, but i am a newbie in this world.i am able to automate previous steps til coming to this web page and now stuck in clicking Cache settings. HTML snippet: <div class=

selenium webdriver(2)—页面对象定位

限于喜欢 提交于 2020-03-04 20:39:14
webdriver的元素定位很灵活,提供了多种定位方式: Id LinkText PartialLinkText Name TagName Xpath ClassName CssSelector 这些方法可以在org.openqa.selenium.By中找到,下面一一道来; 假如有这样的需求:登录安居客网站,搜索陆家嘴附近的二手房源,网页是这样的 这个需求涉及到一个输入框和一个提交按钮,先查看网页源码 在输入框中输入“陆家嘴”然后点击“二手房”按钮,如果能跳转到陆家嘴相关页面就完成了这个需求,我们尝试用webdriver提供的元素定位方法来解决 ID id是唯一标识,通过id来定位是非常快速和准确的 import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.WebElement; public class NewTest {   public static void main(String[] args)   {     System.setProperty("webdriver.chrome.driver",     "C:\\Program