问题
I use PHPUnit_Extensions_Selenium2TestCase Selenium and phpunit and I need make drag and drop one xpath element, on diferent emelent. Like on this screen, to change position on tree (category tree)
回答1:
$srcDrag=$this->byId('draggable');
$targetDrop=$this->byId('droppable');
$stateChecker=$this->byCssSelector('#droppable > p');
$this->assertEquals("Drop here",$stateChecker->text());
$this->moveto($srcDrag);
$this->buttondown();
$this->moveto($targetDrop);
$this->buttonup();
回答2:
Drag and Drop from computer files is not possible. In addition to Shahriar's propose, you could also set value of the input to file location.
$input->value('d:\\1.jpg');
来源:https://stackoverflow.com/questions/23830113/selenium2-phpunit-drag-and-drop-on-xpath