标签: selenium-webdriver

我怎样才能将当前时间加1分钟?webdriver c#

我得到了当前的时间,需要加1分钟,所以提前1分钟,我该怎么做?

string date1 = System.DateTime.Now.ToString("HH:mm");
Run Code Online (Sandbox Code Playgroud)

c# selenium-webdriver

-4
推荐指数
1
解决办法
547
查看次数

Selenium ChromeDriver:无法设置用户数据目录

我将用户主管设置为我的默认用户数据目录(因此我不必担心每次输入站点密码和登录):

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=~/Library/Application\ Support/Google/Chrome/Default/")
browser = webdriver.Chrome(options=options, executable_path=r"chromedriver")
browser.get('https://mail.google.com/mail/u/0/')
print browser.desired_capabilities
Run Code Online (Sandbox Code Playgroud)

现在我希望我的 Gmail 出现,但它要求我登录。

此外,当我打印所需的功能时,似乎根本没有设置用户数据目录:

{u'takesScreenshot': True, u'acceptSslCerts': True, u'networkConnectionEnabled': False, u'mobileEmulationEnabled': False, u'unexpectedAlertBehaviour': u'', u'applicationCacheEnabled': False, u'locationContextEnabled':对,u'rotatable':False,u'chrome':{u'chromedriverVersion':u'2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b)',u'userDataDir':u'2.29.461585 .chromium.Chromium.ihUqp7'}, u'hasTouchScreen': False, u'platform': u'Mac OS X', u'version': u'70.0.3538.110', u'nativeEvents': True, u'handlesAlerts': True, u'takesHeapSnapshot' : True, u'javascriptEnabled': True, u'databaseEnabled': False, u'browserName': u'chrome', u'webStorageEnabled': True, u'browserConnectionEnabled': False, u'cssSelectorsEnabled': True, u' pageLoadStrategy': u'normal'}

我使用的是最新版本的 Selenium (3.141) 和 ChromeDriver (2.29.461585)

python selenium-chromedriver selenium-webdriver

-4
推荐指数
1
解决办法
8303
查看次数

如何设置测试环境以便使用selenium和phantomjs进行测试?

我正在尝试使用Selenium和PhantomJS设置无头测试环境.

设置phantomjs:

我已经创建了一个文件夹c:/phantomjs并将所有phantomjs脚本文件放在那里(下载后).

然后我创建了一个文件夹 C:\xampp\htdocs\testPhantomJS

现在我在我的系统中安装了nodeJS.

然后我遍历到C:\xampp\htdocs\testPhantomJS命令提示符并安装了phantomJS,如下所示:

C:\xampp\htdocs\testPhantomJS>npm install -g phantomjs

图像表示不同的位置.那是因为它来自我同事的电脑.我们都在进行同样的安装,他把图像发给我参考.这就是为什么它与我的文件夹位置不同,但我说的位置,它是我工作的那个.

在此输入图像描述

现在在命令提示符下键入phantomjs,当我们输入时

C:\xampp\htdocs\testPhantomJS>phantomjs

phantom>

设置Selenium-Webdriver

C:\xampp\htdocs\testPhantomJS在命令提示符中遍历并安装了selenium webdriver,如下所示:

C:\xampp\htdocs\testPhantomJS>npm install selenium-webdriver

在此输入图像描述

安装后,文件夹结构如下: 在此输入图像描述

现在我有一个测试脚本test.js,如下所示:

describe('Test example.com', function(){
    before(function(done) {
        client.init().url('http://google.com', done);
    });

    describe('Check homepage', function(){
        it('should see the correct title', function(done) {
            client.getTitle(function(err, title){
                expect(title).to.have.string('Example Domain');
                done();
            });
        });

        it('should see the body', function(done) {
            client.getText('p', function(err, p){
                expect(p).to.have.string(
                    'for illustrative examples in documents.'
                );
                done();
            })
        });
    });

    after(function(done) {
        client.end();
        done(); …
Run Code Online (Sandbox Code Playgroud)

javascript testing selenium phantomjs selenium-webdriver

-6
推荐指数
1
解决办法
1263
查看次数

为 Selenium 测试构建定位器时属性 xpath="1" 的意义是什么

xpath="1"最近,我在基于角度的应用程序中偶然发现了一个带有属性的元素。

HTML:

x路径=1

我无法找到有关此属性的任何详细信息,以及它在基于 Selenium 的测试的 xpath/cssSelector 中可能产生的影响和使用情况。

有人可以帮我任何方向吗?

selenium xpath selenium-webdriver angular chropath

-6
推荐指数
1
解决办法
322
查看次数