GVKun编程网logo

Django Jenkins处理到Selenium服务器时引发WebDriverException(selenium grid jenkins)

15

关于DjangoJenkins处理到Selenium服务器时引发WebDriverException和seleniumgridjenkins的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于

关于Django Jenkins处理到Selenium服务器时引发WebDriverExceptionselenium grid jenkins的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于appium 报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occu、appium启动服务,链接app报错elenium.common.exceptions.WebDriverException: Message: An unknown server-side erro、Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时、org.openqa.selenium.InvalidCookieDomainException:使用Selenium和WebDriver禁止文档访问Cookie等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

Django Jenkins处理到Selenium服务器时引发WebDriverException(selenium grid jenkins)

Django Jenkins处理到Selenium服务器时引发WebDriverException(selenium grid jenkins)

我通过命令启动Selenium服务器中心

java -jar selenium-server-standalone-2.33.0.jar -role hub

和Selenium服务器节点通过命令

java -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=htmlunit

然后我试图执行代码:

from selenium import webdriverfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesserver =  ''http://localhost:4444/wd/hub''dc = DesiredCapabilities.HTMLUNITbrowser = webdriver.Remote(server, dc)browser.get(''http://localhost:8000'')

之后一切都很好。但是,当我尝试开始进行詹金斯测试时:

from django.test import TestCase, LiveServerTestCasefrom selenium.webdriver.common import proxyfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesfrom selenium.webdriver.remote.webdriver import WebDriverclass SeleniumTest(LiveServerTestCase):    @classmethod    def setUpClass(cls):        p = proxy.Proxy({        ''proxyType'': proxy.ProxyType().MANUAL,        ''httpProxy'': ''127.0.0.1:4444'',        })        capabilities = DesiredCapabilities().HTMLUNIT        cls.selenium = WebDriver(desired_capabilities=capabilities, proxy=p)        super(SeleniumTest, cls).setUpClass()    @classmethod    def tearDownClass(cls):        cls.selenium.quit()        super(SeleniumTest, cls).tearDownClass()    def test_javascript_basket(self):        self.selenium.get(''http://localhost:8000'')

我收到以下错误,包含在追溯中:

WebDriverException:消息:u’\ n \ n \ n错误:无法检索到所请求的URL \ n \ n \ n \ n

错误

\ n

所请求的网址无法检索

\ n \ n


\ n \ n \ n

尝试检索URL时遇到以下错误:a href =“ http:// localhost:4444 / wd / hub / session”
localhost:4444 / wd / hub / session ap \ n \ n \ n

与127.0.0.1的连接失败。

\ n

\ n \ n系统返回: (111)连接被拒绝 \ n \ n

远程主机或网络可能已关闭。请重试该请求。

\ n \ n

您的缓存管理员是网站管理员。

\ n \ n
\ n \ n \ n


\ n \ n

由localhost(squid / 3.1.6)于2013年6月10日星期一格林尼治标准时间生成

\ n \ n \ n’

这是怎么回事?为什么从Jenkins测试连接到Selenium服务器无法正常工作?

python==2.7.3Django==1.5django-jenkins==0.14.0selenium==2.33.0

更新: 如果我使用的是Firefox WebDriver而不是HTMLUNIT,则Firefox在行后打开

cls.selenium = WebDriver(desired_capabilities=capabilities, proxy=p)

,但稍后引发上述异常。

解决了, 我只是添加到setUpClass()方法:

import os. . .    def setUpClass(cls):        os.environ[''NO_PROXY''] = ''127.0.0.1''

答案1

小编典典

我以这种方式解决了问题(使用了 phantom-js 而不是 HTMLUNIT ,因为它是唯一剩余的稳定版本的代码)。

from django.test import LiveServerTestCasefrom selenium import webdriverfrom os import environclass SeleniumTestCase(LiveServerTestCase):    __test__ = False    @classmethod    def setUpClass(cls):        environ[''NO_PROXY''] = ''127.0.0.1''  # The key point        cls.selenium = webdriver.PhantomJS(service_args=[''--proxy-type=none''])            super(SeleniumTestCase, cls).setUpClass()    @classmethod    def tearDownClass(cls):        cls.selenium.close()        cls.selenium.quit()        super(SeleniumTestCase, cls).tearDownClass()class TestFoo(SeleniumTestCase):        def setUp(self):        # do something before every test method runs        pass    def test_foo(self):        # test        pass

appium 报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occu

appium 报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occu

appium进行手机浏览器的自动化测试启动代码如下

#使用手机浏览器进行自动化测试
import time
from appium import webdriver

#自动化配置信息
des={
'platformName': 'Android',
'platformVersion': '8.0', #填写android虚拟机的系统版本
'deviceName': 'SamSung galaxy S9', #填写安卓虚拟机的设备名称---值可以随便写
'browserName': 'chrome', # 直接指定浏览器名称参数为chrome【重点添加了这一步】
'udid': '192.168.235.103:5555', # 填写通过命令行 adb devices 查看到的 uuid
'noreset': True, # 确保自动化之后不重置app
'unicodeKeyboard': True,
'resetKeyboard': True,
'chromedriverExecutable': r"C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe" #使用指定的浏览器驱动-匹配手机上的谷歌浏览器
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', des)
driver.implicitly_wait(5)
driver.get('http://hao.uc.cn/') #打开UC网页

 

报错如下:

selenium.common.exceptions.WebDriverException:
Message: An unkNown server-side error occurred while processing the command. Original error: Can't stop process;
it's not currently running (cmd: ''C:/Program Files/Appium/resources/app/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe' --url-base\=wd/hub --port\=8001 --adb-port\=5037 --verbose')

 

原因

折腾了相当久 ,两个晚上 才找到原因,代码没有问题,问题出在浏览器版本与chromedriver版本不一致导致的

解决办法

下载与浏览器版本一致的驱动后,再次启动就成功了。

对应浏览器版本的Chromedriver下载地址:https://npm.taobao.org/mirrors/chromedriver

chromedriver版本匹配地址:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md

 

appium启动服务,链接app报错elenium.common.exceptions.WebDriverException: Message: An unknown server-side erro

appium启动服务,链接app报错elenium.common.exceptions.WebDriverException: Message: An unknown server-side erro

selenium.common.exceptions.WebDriverException: Message: An unkNown server-side error occurred while processing the command.
Original error: Error executing adbExec. Original error: 'Command 'D:\\tools\\Android\\android_sdk\\platform-tools\\adb.exe -P 5037 -s 3EP7N19314001798 shell
pm install -g /data/local/tmp/appium_cache/3d97225b036c28750562ef8962defee6b1af19a4.apk' exited with code 1'; Stderr: ''; Code: '1'

 

desired_caps = {
"automationName":"UiAutomator2",#使用哪个自动化引擎,appium1.x可以不用写
"platformName":"Android",#使用哪个移动操作系统平台
"platformVersion":'9',#移动操作系统版本
"deviceName":"3EP7N19314001798",#使用的移动设备或模拟器的种类,需要在cmd命令下,敲adb devices查看
"appPackage":"com.ulic.misp.asp",#所要测试的app的包名,获取命令:aapt dump badging apk路径,查看package: name=
"appActivity":"com.ulic.misp.asp.ui.loading.GuideActivity",#所要测试app的入口页面,获取命令:aapt dump badging apk路径,查看launchable-activity: name='
"noreset":True#在此会话之前,请勿重置应用程序状态
}
driver= webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)


查看报错,appium无法清除应用缓存

1、重启下appinum
2、检查下开发者选项中的配置

Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时

Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时

code is correct. added code for time out exception. implicitlyWait added
public class SeleniumClass {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver","C:\\\\Drivers\\\\chromedriver.exe");
        //System.setProperty("webdriver.gecko.driver","F:/Selenium/Jars and Drivers/Drivers/Firefox/geckodriver-v0.29.0-win64/geckodriver.exe");
        WebDriver driver = new ChromeDriver();
        //WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
        driver.get("http://www.google.com");
    }

}
,

https://sites.google.com/a/chromium.org/chromedriver/

尝试 - 我下载了最新的稳定版本并且它有效。

org.openqa.selenium.InvalidCookieDomainException:使用Selenium和WebDriver禁止文档访问Cookie

org.openqa.selenium.InvalidCookieDomainException:使用Selenium和WebDriver禁止文档访问Cookie

我正在尝试将Cookie推送到上一个会话存储的Selenium firefox webdriver,但出现错误:

org.openqa.selenium.InvalidCookieDomainException: Document is cookie-averse

我阅读了此HTML Standard
Cookie规章,一点也不懂。

因此,问题是如何将cookie推送到上一个存储的webdriver会话中?

答案1

小编典典

此错误消息…

org.openqa.selenium.InvalidCookieDomainException: Document is cookie-averse

……意味着非法企图在与当前文档不同的域下设置cookie。


细节

具体根据HTML的生活标准规范一个Document Object可被归类为在以下情况下一个Cookie规避文档对象:

  • 没有的文件 Browsing Context
  • URL方案不是网络方案的文档。

深潜

对于无效的cookie域,当您访问不喜欢cookie的文档(例如本地磁盘上的文件)时,可能会发生此错误。

举个例子:

  • 样例代码:
        from selenium import webdriver    from selenium.common import exceptions    session = webdriver.Firefox()    session.get("file:///home/jdoe/document.html")    try:        foo_cookie = {"name": "foo", "value": "bar"}        session.add_cookie(foo_cookie)    except exceptions.InvalidCookieDomainException as e:        print(e.message)
  • 控制台输出:
    InvalidCookieDomainException: Document is cookie-averse

如果您已存储来自域的example.comcookie, 则无法 通过webdriver会话将这些存储的cookie
推送到任何其他不同的域,例如example.edu。存储的Cookie只能在中使用example.com。此外,要在将来自动登录用户,您只需要存储一次Cookie,即用户登录后的时间。在添加Cookie之前,您需要浏览到收集Cookie的相同域。


例如,一旦用户在应用程序中登录,就可以存储cookie,如下所示:

    from selenium import webdriver    import pickle    driver = webdriver.Chrome()    driver.get(''http://demo.guru99.com/test/cookie/selenium_aut.php'')    driver.find_element_by_name("username").send_keys("abc123")    driver.find_element_by_name("password").send_keys("123xyz")    driver.find_element_by_name("submit").click()
# storing the cookiespickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))driver.quit()

稍后,如果您希望用户自动登录,则需要先浏览到特定的域/ url,然后必须添加cookie,如下所示:

    from selenium import webdriver    import pickle    driver = webdriver.Chrome()    driver.get(''http://demo.guru99.com/test/cookie/selenium_aut.php'')    # loading the stored cookies    cookies = pickle.load(open("cookies.pkl", "rb"))    for cookie in cookies:        # adding the cookies to the session through webdriver instance        driver.add_cookie(cookie)    driver.get(''http://demo.guru99.com/test/cookie/selenium_cookie.php'')

关于Django Jenkins处理到Selenium服务器时引发WebDriverExceptionselenium grid jenkins的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于appium 报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occu、appium启动服务,链接app报错elenium.common.exceptions.WebDriverException: Message: An unknown server-side erro、Chrome浏览器中的Selenium在线程“main”org.openqa.selenium.WebDriverException中显示异常:等待驱动程序服务器启动超时、org.openqa.selenium.InvalidCookieDomainException:使用Selenium和WebDriver禁止文档访问Cookie等相关知识的信息别忘了在本站进行查找喔。

本文标签: