草庐IT

pytest-selenium

全部标签

python - 使用 Selenium FirefoxDriver 在 Google 搜索上禁用样式

followingcode在加载了SeleniumFirefoxwebdriver的页面上禁用样式表和图像:fromseleniumimportwebdriverfirefox_profile=webdriver.FirefoxProfile()firefox_profile.set_preference('permissions.default.stylesheet',2)firefox_profile.set_preference('permissions.default.image',2)driver=webdriver.Firefox(firefox_profile)drive

javascript - 如何使用 Python 3 通过 selenium 或 javascript 更改网络 whatsapp 中的事件聊天

我正在通过Python通过selenium引导网络whatsapp,我想知道是否可以更改事件(顶部聊天。如果收到消息,聊天将不会设置为事件,它将始终保留在背景。在Javascript中,可以通过以下方式在控制台中查看所有聊天的列表:Store.chat.models事件聊天存储在位置零,但是用另一个聊天覆盖位置零不会使聊天处于事件状态。我发现有一个名为“x_active”的变量,如果单击聊天并将其查看为true(而所有其他人都将其设置为false),该变量会发生变化。例如:Store.Chat.models[0].__x_active但是在chrome控制台选项卡中设置变量或true或

Python django : How to call selenium. set_speed() 与 django LiveServerTestCase

为了运行我的功能测试,我使用LiveServerTestCase。我想调用不在webdriver中但在selenium对象中的set_speed(以及其他方法,set_speed只是一个示例)。http://selenium.googlecode.com/git/docs/api/py/selenium/selenium.selenium.html#module-selenium.selenium我的LiveServerTestCase子类fromseleniumimportwebdriverclassSeleniumLiveServerTestCase(LiveServerTestC

python - 如何在 selenium for python 中转义 xpath 1.0 中的单引号

我在seleniumpython脚本中使用了以下代码行:fromseleniumimportwebdriverdriver.find_element_by_xpath(u"//span[text()='"+cat2+"']").click()cat2是来自数据库列表的变量,我是这样得到的:db=Database()sql="SELECT*FROMmissinglisteproduit=db.select(sql)forrecordinlisteproduit:cat2=record[6]问题是当变量包含这样的文本时:cat2=Debimetred'air那么该脚本将无法运行,因为它是一

python - Py2exe 和 selenium - IOError : [Errno 2] No such file or directory: '\\dist\\main.exe\\selenium\\webdriver\\firefox\\webdriver_prefs.json'

我写了一个简单的应用程序,它使用selenium浏览页面并下载它们的源代码。现在我想让我的应用程序Windows可执行。我的setup.py文件:fromdistutils.coreimportsetupimportpy2exe,sys,ossys.argv.append('py2exe')setup(options={'py2exe':{'bundle_files':1,"dll_excludes":['w9xpopen.exe','MSVCP90.dll','mswsock.dll','powrprof.dll','MPR.dll','MSVCR100.dll','mfc90.dl

python - 如何导入 pytest monkeypatch 插件?

我想使用pytestmonkeypatch插件,但我不知道如何导入它。我试过:importmonkeypath导入pytest.monkeypatch从pytest导入monkeypatch 最佳答案 它不是插件,它是内置的pytestfixture.简而言之,这意味着您只需编写一个带有monkeypatch参数的测试,测试就会将monkeypatch对象作为该参数。您链接的页面有一个简单的示例:deftest_some_interaction(monkeypatch):monkeypatch.setattr("os.getcwd"

异步和等待方法的 Python pytest 用例

我正在尝试为以下异步、等待方法编写pytest,但我一无所获。classUserDb(object):asyncdefadd_user_info(self,userInfo):returnawaitself.post_route(route='users',json=userInfo)asyncdefpost_route(self,route=None,json=None,params=None):uri=self.uri+routeifrouteelseself.uriasyncwithself.client.post(uri,json=json,params=params)asre

python - 使用 Chrome 时出现 Selenium "selenium.common.exceptions.NoSuchElementException"

我正在尝试播放QWOP在Chrome上使用Selenium但我不断收到以下错误:selenium.common.exceptions.NoSuchElementException:Message:nosuchelement:Unabletolocateelement{"method":"id","selector":"window1"(Sessioninfo:chrome=63.0.3239.108(Driverinfo:chromedriver=2.34.522913(36222509aa6e819815938cbf2709b4849735537c),platform=Linux4.

python - pytest 是否支持 "default"标记?

我正在使用pytest测试嵌入式系统的python模型。要测试的功能因平台而异。(我在此上下文中使用“平台”来表示嵌入式系统类型,而不是操作系统类型)。组织我的测试最直接的方法是根据平台类型将它们分配到目录。/platform1/platform2/etc.pytest/platform1由于许多功能跨平台重叠,这很快就变得难以支持。从那以后,我将我的测试移到了一个目录中,每个功能区域的测试分配给一个文件名(例如test_functionalityA.py)。然后,我使用pytest标记来指示文件中的哪些测试适用于给定平台。@pytest.mark.all_platformsdefte

Web自动化之Selenium常用操作

本文总结使用selenium进行web/UI自动化时,会用到的一些常用操作。定位元素driver.find_element_by_xpath()#1、绝对路径2、元素属性3、层级和属性结合4、使用逻辑运算符driver.find_element_by_id()#根据id定位,HTML规定id属性在HTML文档中必须是唯一的driver.find_element_by_name()#name属性定位driver.find_element_by_class_name()#class属性定位driver.find_element_by_tag_name()#标签名字定位因为标签基本都不是唯一的,所以