Giter Site home page Giter Site logo

pyautotest's People

Contributors

defnngj avatar fnngj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pyautotest's Issues

发现错误,conftest.py中new_report_time()路径错误

new_report_time() 方法中路径错误,return files[-1],当存在日志的时候,倒数第一个文件是__init__.py,所以save_screenshot方法中的路径就会错误,应该改成 return files[-2],才能正确获取到第一个日志文件夹

在poium中的方法怎么使用page中的定位方式呢?

          def get_text(self, css_selector):
        """
        JavaScript API, Only support css positioning
        Get element text, Only support css positioning
        """
        js = 'return document.querySelector("{css}").textContent;'.format(css=css_selector)
        return self.driver.execute_script(js)

使用:

page.get_text('css定位')

但是我在page中已经定义了:

login_btn = PageElement(css='#login > button', describe='登录按钮')

怎么样在page.get_text()中使用已经写好的的login_btn 定位呢?

控制台输出

你好,我尝试运行了一下 chrome headless 模式,控制台有部分乱码,想请教下这是什么东西的输出,怎么让它不乱码
微信截图_20230413133606

版本没问题,但是一直NameError: name 'driver' is not defined

2020-01-15 11:35:56,042 - INFO - 回归模式,开始执行✈✈!
============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-4.3.0, py-1.8.1, pluggy-0.13.1 -- C:\Users\bima\AppData\Local\Programs\Python\Python37\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.1', 'Platform': 'Windows-8.1-6.3.9600-SP0', 'Packages': {'pytest': '4.3.0', 'py': '1.8.1', 'pluggy': '0.13.1'}, 'Plugins': {'html': '2.0.0', 'metadata': '1.8.0', 'rerunfailures': '7.0'}, 'JAVA_HOME': 'F:\install\jdk1.8.0_111'}
rootdir: F:\Workspaces\pyautoTest, inifile:
plugins: html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collecting ... collected 4 items

test_dir/test_baidu.py::TestSearch::test_baidu_search_case
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 210, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 250, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 271, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pytest_rerunfailures.py", line 176, in pytest_runtest_protocol
INTERNALERROR> reports = runtestprotocol(item, nextitem=nextitem, log=False)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\runner.py", line 87, in runtestprotocol
INTERNALERROR> rep = call_and_report(item, "setup", log)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\runner.py", line 175, in call_and_report
INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 203, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "F:\Workspaces\pyautoTest\conftest.py", line 74, in pytest_runtest_makereport
INTERNALERROR> capture_screenshot(case_name)
INTERNALERROR> File "F:\Workspaces\pyautoTest\conftest.py", line 121, in capture_screenshot
INTERNALERROR> driver.save_screenshot(image_dir)
INTERNALERROR> NameError: name 'driver' is not defined

刚下到本地跑了一下报错了

已经把需要的库都安装好
INTERNALERROR> File "D:\PycharmProjects\pyautoTest-master\conftest.py", line 99, in capture_screenshots INTERNALERROR> RunConfig.driver.save_screenshot(image_dir) INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'save_screenshot'

代码点击百度设置会报错无法识别到

设置是个鼠标浮停的效果,这里会报错, 怎么解决这个问题?
test_baidu.py
def test_baidu_search_setting(self, browser, base_url):
page.settings.click()

class BaiduPage(Page):
settings = PageElement(link_text="设置", describe="设置下拉框")

获取不到元素的text

    def test_LoginBySms_Success(self, browser, base_url):
        page = Login_Page(browser)
        print(page.login_success.text)

在selenium 下无法获取元素的text
E AttributeError: 'NoneType' object has no attribute 'text'

AttributeError: 'CollectReport' object has no attribute 'description'

  • python3 run_tests.py
    回归模式,执行完成生成测试结果
    ============================= test session starts ==============================
    platform linux -- Python 3.6.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0 -- /bin/python3
    cachedir: .pytest_cache
    metadata: {'Python': '3.6.3', 'Platform': 'Linux-3.10.0-693.el7.x86_64-x86_64-with-centos-7.4.1708-Core', 'Packages': {'pytest': '4.6.3', 'py': '1.8.0', 'pluggy': '0.12.0'}, 'Plugins': {'metadata': '1.8.0', 'html': '1.21.1', 'rerunfailures': '7.0'}, 'BUILD_NUMBER': '34', 'BUILD_ID': '34', 'BUILD_URL': 'http://192.168.0.196:8081/job/crm_auto_test/34/', 'NODE_NAME': 'master', 'JOB_NAME': 'crm_auto_test', 'BUILD_TAG': 'jenkins-crm_auto_test-34', 'EXECUTOR_NUMBER': '1', 'JENKINS_URL': 'http://192.168.0.196:8081/', 'JAVA_HOME': '/home/gaofenyun/app/jdk1.8.0_211', 'WORKSPACE': '/home/gaofenyun/.jenkins/workspace/crm_auto_test'}
    plugins: metadata-1.8.0, html-1.21.1, rerunfailures-7.0
    collecting ... collected 0 items / 1 errors
    INTERNALERROR> Traceback (most recent call last):
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 206, in wrap_session
    INTERNALERROR> session.exitstatus = doit(config, session) or 0
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 249, in _main
    INTERNALERROR> config.hook.pytest_collection(session=session)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in call
    INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
    INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 81, in
    INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR> return outcome.get_result()
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR> raise ex[1].with_traceback(ex[2])
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR> res = hook_impl.function(*args)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 259, in pytest_collection
    INTERNALERROR> return session.perform_collect()
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 495, in perform_collect
    INTERNALERROR> items = self._perform_collect(args, genitems)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 534, in _perform_collect
    INTERNALERROR> self.items.extend(self.genitems(node))
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 772, in genitems
    INTERNALERROR> for x in self.genitems(subnode):
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/_pytest/main.py", line 774, in genitems
    INTERNALERROR> node.ihook.pytest_collectreport(report=rep)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in call
    INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
    INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 81, in
    INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR> return outcome.get_result()
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR> raise ex[1].with_traceback(ex[2])
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR> res = hook_impl.function(*args)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pytest_html/plugin.py", line 519, in pytest_collectreport
    INTERNALERROR> self.append_failed(report)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pytest_html/plugin.py", line 304, in append_failed
    INTERNALERROR> self._appendrow('Error', report)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pytest_html/plugin.py", line 273, in _appendrow
    INTERNALERROR> result = self.TestResult(outcome, report, self.logfile, self.config)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pytest_html/plugin.py", line 130, in init
    INTERNALERROR> report=report, cells=cells)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in call
    INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
    INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/manager.py", line 81, in
    INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR> return outcome.get_result()
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR> raise ex[1].with_traceback(ex[2])
    INTERNALERROR> File "/usr/local/python3/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR> res = hook_impl.function(*args)
    INTERNALERROR> File "/home/gaofenyun/test_code/new_crm_poium/conftest.py", line 145, in pytest_html_results_table_row
    INTERNALERROR> cells.insert(2, html.td(report.description))
    INTERNALERROR> AttributeError: 'CollectReport' object has no attribute 'description'

这种错误是什么引起的呢,这是我通过jenkins 使用selenium grid插件启动的,在我本地是可以正常运行。是什么原因呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.