首页 \ 问答 \ 使用PHPUnit的Selenium没有加载页面(Selenium with PHPUnit not loading page)

使用PHPUnit的Selenium没有加载页面(Selenium with PHPUnit not loading page)

我正在尝试使用phpunit和phpunit-selenium为php项目制作测试套件。 在我的作曲家文件中,我有

"require-dev": {
    "phpunit/phpunit": "^5.7",
    "phpunit/phpunit-selenium": "^3.0"
}

安装的phpunit版本是5.7.4我使用selenium-server-standalone-3.0.1.jar作为selenium服务器。 我用java -Dwebdriver.gecko.driver =“C:\ Harlan \ Selenium \ geckodriver.exe”启动服务器-jar selenium-server-standalone-3.0.1.jar

在我的测试课中,我有

require_once dirname(__FILE__) . '/../../vendor/autoload.php';
class UserSubscriptionTest extends PHPUnit_Extensions_Selenium2TestCase {

public function setUp() {
    $this->setHost('localhost');
    $this->setPort(4444);
    $this->setBrowserUrl('http://localhost/cwckids/web/user/login');
    $this->setBrowser('firefox');


}

public function tearDown() {
    $this->stop();
}



public function testFormSubmissionWithUsername()
{
$this->byName('login-form[login]')->value('admin');
$this->byName('login-form[password]')->value('mypassword');
$this->byId('login-form')->submit();

$content = $this->byTag('body')->text();
$this->assertEquals('Everything is Good!', $content, 'something wrong!!');
}    
}

我的问题是firefox浏览器打开但没有加载页面http:// localhost / cwckids / web / user / login

测试立即失败,因为它无法找到元素。 它给出一条消息说无法找到元素:{“method”:“name”,“selector”:“login-form [login]”}

我找不到问题的解决方案。 它有些版本不兼容吗? 我试过几个版本的Firefox和selenium服务器。 我的Firefox版本是50.1.0。 如果是版本不兼容可以有人建议正确版本吗? 谢谢

完整的痕迹

C:\ xampp \ htdocs \ seleniumtest> phpunit tests / acceptance / UserSubscriptionTest.php由Sebastian Bergmann和贡献者提供的PHPUnit 5.7.4。

E 1/1(100%)

时间:6.51秒,内存:9.25MB

有1个错误:

1)UserSubscriptionTest :: testFormSubmissionWithUsername PHPUnit_Extensions_Selenium2TestCase_WebDriverException:无法找到元素:{“method”:“name”,“selector”:“login-form [login]”}有关此错误的文档,请访问: http:// seleniumhq。 org / exceptions / no_such_element.html构建信息:版本:'2.53.1',修订版:'a36b8b1',时间:'2016-06-30 17:37:03'系统信息:主机:'DESKTOP-I0LAEAM',ip :'192.168.8.101',os.name:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8.0_77'驱动程序信息:driver.version:unknown

C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase \ Driver.php:165 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase \ CommandsHolder.php:108 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase \ Element \ Accessor.php:134 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit -selenium \ PHPUnit \ Extensions \ Selenium2TestCase \ Element \ Accessor.php:175 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase \ Element \ Accessor.php:108 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase.php:394 C:\ xampp \ htdocs \ seleniumtest \ tests \ acceptance \ UserSubscriptionTest.php:66 C:\ xampp \ htdocs \ seleniumtest \ tests \ acceptance \ UserSubscriptionTest.php:66 C:\ xampp \ htdocs \ seleniumtest \ vendor \ phpunit \ phpunit-selenium \ PHPUnit \ Extensions \ Selenium2TestCase.php:348 C:\ xampp \ htdocs \ seleniumtest \ vendor \ p hpunit \ PHPUnit的硒\ PHPUnit的\扩展\ Selenium2TestCase.php:314

错误! 测试:1,断言:0,错误:1。


I am trying to make a test suit for a php project using phpunit and phpunit-selenium. In my composer file I have

"require-dev": {
    "phpunit/phpunit": "^5.7",
    "phpunit/phpunit-selenium": "^3.0"
}

The installed phpunit version is 5.7.4 I am using selenium-server-standalone-3.0.1.jar as the selenium server. I start the server with java -Dwebdriver.gecko.driver="C:\Harlan\Selenium\geckodriver.exe" -jar selenium-server-standalone-3.0.1.jar

In my test class I have

require_once dirname(__FILE__) . '/../../vendor/autoload.php';
class UserSubscriptionTest extends PHPUnit_Extensions_Selenium2TestCase {

public function setUp() {
    $this->setHost('localhost');
    $this->setPort(4444);
    $this->setBrowserUrl('http://localhost/cwckids/web/user/login');
    $this->setBrowser('firefox');


}

public function tearDown() {
    $this->stop();
}



public function testFormSubmissionWithUsername()
{
$this->byName('login-form[login]')->value('admin');
$this->byName('login-form[password]')->value('mypassword');
$this->byId('login-form')->submit();

$content = $this->byTag('body')->text();
$this->assertEquals('Everything is Good!', $content, 'something wrong!!');
}    
}

My problem is that the firefox browser opens up but doesn't load the page http://localhost/cwckids/web/user/login

The test fails immediately because it cannot find the elements. It give a message saying Unable to locate element: {"method":"name","selector":"login-form[login]"}

I couldn't find a solution for the problem. Is it some version incompatibility? I tried with a few versions of Firefox and also selenium server. My Firefox version is 50.1.0. If it is a version incompatibility can someone suggest correct versions? Thanks

The complete trace

C:\xampp\htdocs\seleniumtest>phpunit tests/acceptance/UserSubscriptionTest.php PHPUnit 5.7.4 by Sebastian Bergmann and contributors.

E 1 / 1 (100%)

Time: 6.51 seconds, Memory: 9.25MB

There was 1 error:

1) UserSubscriptionTest::testFormSubmissionWithUsername PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to locate element: {"method":"name","selector":"login-form[login]"} For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' System info: host: 'DESKTOP-I0LAEAM', ip: '192.168.8.101', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77' Driver info: driver.version: unknown

C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:165 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\CommandsHolder.php:108 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Element\Accessor.php:134 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Element\Accessor.php:175 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Element\Accessor.php:108 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:394 C:\xampp\htdocs\seleniumtest\tests\acceptance\UserSubscriptionTest.php:66 C:\xampp\htdocs\seleniumtest\tests\acceptance\UserSubscriptionTest.php:66 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:348 C:\xampp\htdocs\seleniumtest\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:314

ERRORS! Tests: 1, Assertions: 0, Errors: 1.


原文:https://stackoverflow.com/questions/41265019
更新时间:2022-10-31 22:10

最满意答案

C ++ 03和C ++ 11的ABI没有区别,因此目标文件不是问题。 您的库可以尽可能多地在内部使用C ++ 11,但C ++ 11语法的头文件不能用于C ++ 03项目,编译器会引发错误。


The ABI of C++03 and C++11 doesn't differ, so object files aren't a problem. Your library can use C++11 internally as much as you want, but headers with C++11 syntax can't be used for C++03 projects, the compiler throws errors.

相关问答

更多
  • 如果您使用的是C ++ 0x兼容的编译器和标准库,则无需执行任何操作即可从第一个示例中获得更好的性能。 get_vector(_n, _m)的返回值是一个临时变量, std::vector的移动构造函数(一个构造函数接受右值引用)将自动被调用,而不再需要进一步的工作。 通常,非库编写者不需要直接使用右值引用; 你只会自动获得相当一部分好处。 If you're using a C++0x-compatible compiler and standard library, you get better per ...
  • 规则很简单:它是你如何声明它。 int i = 5; auto a1 = i; // value auto & a2 = i; // reference 下一个例子证明: #include #include template< typename T > struct A { static void foo(){ std::cout<< "value" << std::endl; } }; template< typename T > s ...
  • 你使用new是一个红旗,尤其是在std::vector 。 std::vector s支持本地移动语义。 他们是一个内存管理课程。 内存管理类的手动内存管理是一个BIG红旗。 遵循0的规则。 =default你的移动构造函数,移动赋值,复制构造函数,析构函数和复制赋值。 从矢量中删除* 。 不要分配它。 用data->替换data-> data. 你应该做的第二件事是改变: MTensor::Tensor1D scalarProduct1D(MTensor::Tensor1D t1, double scal ...
  • 你不能复制和移动一次,除非你改变你的类的设计,并把它们的构造函数转换成(可能是SFINAE约束的)模板化转发构造函数( Yakk的答案显示了如何 )。 虽然这样做可以在执行rvalues时执行一次移动和不复制,并且在提供了lvalue时执行一次复制和不移动,但在大多数情况下这是一种矫枉过正的行为。 作为基于模板的转发构造函数的替代方法,您可以在基类和派生类中提供两个构造函数:一个用于右值引用,另一个用于左值引用const 。 但是,在大多数情况下,这是一个不必要的复杂情况(并且在参数数量增加时不能很好地扩展 ...
  • 我认为它应该编译: std::make_tuple()的结果是一个临时的std::tuple ,它应该移动构造它的成员。 更确切地说, std::tuple的移动构造函数是默认的,这应该导致成员移动构造。 显然,没有必要将std::make_tuple()的结果std::make_tuple() t 。 如果您选择引入此变量,则返回时不应该使用std::move(t) :当return语句中的表达式是局部变量时,无论如何它都被视为rvalue。 但是,额外的std::move()禁止 ...
  • 在将var传递给some_func时,C ++ 11会自动使用移动语义, 不,这是一个复制结构,因为var是一个左值。 该语言不允许编译器执行其他任何操作。 唯一一次隐式移动左值而不是复制左边是从函数返回它时,例如some_func这一行将使用移动构造函数: return var; 并再次重新分配给var,因为var的原始值无论如何都会被销毁? 这将使用Foo的移动赋值运算符,因为它为var分配了一个rvalue。 如果您使用some_func(std::move(var))或者如果您这样写它,则可以避免 ...
  • getTest(1) + getTest(2) + getTest(3)的结果与Test::operator+(const Test&)的返回类型具有相同的类型。 它是Test& ,因此是左值。 operator +通常是非成员重载,它返回临时值: Test operator + (const Test& a, const Test& b) 要么 Test operator + (Test a, const Test& b) 实现operator +=作为成员的加分点,并在非成员operator+的实现 ...
  • C ++ 03和C ++ 11的ABI没有区别,因此目标文件不是问题。 您的库可以尽可能多地在内部使用C ++ 11,但C ++ 11语法的头文件不能用于C ++ 03项目,编译器会引发错误。 The ABI of C++03 and C++11 doesn't differ, so object files aren't a problem. Your library can use C++11 internally as much as you want, but headers with C++11 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)