Commit 0deafe0e authored by mkroon's avatar mkroon

Upgrade to selenium webdriver and facebook/webdriver api (WIP)

parent 23e31ac1
<?php
/*******************************************************************************
*
* LEIDEN OPEN VARIATION DATABASE (LOVD)
*
* Created : 2016-04-21
* Modified : 2016-05-30
* For LOVD : 3.0-16
*
* Copyright : 2016 Leiden University Medical Center; http://www.LUMC.nl/
* Programmers : M. Kroon <m.kroon@lumc.nl>
*
*
* This file is part of LOVD.
*
* LOVD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LOVD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LOVD. If not, see <http://www.gnu.org/licenses/>.
*
*************/
class LOVDScreenshotListener implements PHPUnit_Framework_TestListener {
// Based on "../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php";
protected $directory;
public function __construct($directory)
{
$this->directory = $directory;
}
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{
$this->storeAScreenshot($test);
}
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->storeAScreenshot($test);
}
private function storeAScreenshot(PHPUnit_Framework_Test $test)
{
if ($test instanceof LOVDSeleniumWebdriverBaseTestCase)
{
try {
$file = $this->directory . '/' . get_class($test) . '__' . $test->getName() . '__' . date('Y-m-d\TH-i-s') . '.png';
$test->driver->takeScreenshot($file);
$this->log('Screenshot captured.', $file);
} catch (Exception $e) {
$file = $this->directory . '/' . get_class($test) . '__' . $test->getName() . '__' . date('Y-m-d\TH-i-s') . '.txt';
file_put_contents($file, "Screenshot generation doesn't work." . "\n"
. $e->getMessage() . "\n"
. $e->getTraceAsString());
$this->log('Failed to capture screenshot.', $file);
}
}
}
private function log($message, $path) {
print($message . "\nSee file: " . $path);
}
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
public function startTest(PHPUnit_Framework_Test $test) {}
public function endTest(PHPUnit_Framework_Test $test, $time) {}
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {}
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {}
}
......@@ -4,7 +4,7 @@
* LEIDEN OPEN VARIATION DATABASE (LOVD)
*
* Created : 2016-03-02
* Modified : 2016-03-02
* Modified : 2016-05-30
* For LOVD : 3.0-15
*
* Copyright : 2016 Leiden University Medical Center; http://www.LUMC.nl/
......@@ -29,27 +29,76 @@
*************/
abstract class LOVDSeleniumBaseTestCase extends PHPUnit_Extensions_SeleniumTestCase
{
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
protected $captureScreenshotOnFailure = TRUE;
protected $screenshotPath;
protected $screenshotUrl;
protected $baseUrl;
abstract class LOVDSeleniumWebdriverBaseTestCase extends PHPUnit_Framework_TestCase
{
// Base class for all Selenium tests.
// public webdriver instance
public $driver;
protected function setUp()
{
// Set selenium general settings.
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser("firefox");
$this->setBrowserUrl(ROOT_URL);
$this->shareSession(true);
// Set selenium screenshot paths.
$this->screenshotUrl = ROOT_URL . '/tests/test_results/error_screenshots';
$this->screenshotPath = ROOT_PATH . '/tests/test_results/error_screenshots';
// This method is called before every test invocation.
$this->driver = getWebDriverInstance();
}
}
protected function waitUntil($condition)
{
// Convenience function to let the webdriver wait for a standard amount
// of time on the given condition.
return $this->driver->wait(WEBDRIVER_MAX_WAIT_DEFAULT, WEBDRIVER_POLL_INTERVAL_DEFAULT)
->until($condition);
}
protected function enterValue($locator, $sText)
{
// Convenience function to let the webdriver type text $text in an
// element specified by $locator.
$element = $this->driver->findElement($locator);
$element->click();
// Try to clear field and set value for a time period. This is needed
// for some fields that are set read-only until they get focus, then
// the first sendKeys() calls may be ignored as javascript has to be
// executed.
$this->waitUntil(function ($driver) use ($element, $sText) {
if (!is_null($element->getAttribute('readonly'))) {
return false;
}
$element->clear();
$element->sendKeys($sText);
return $element->getAttribute('value') == $sText;
});
}
protected function setCheckBoxValue($locator, $bSetChecked) {
$element = $this->driver->findElement($locator);
if (($bSetChecked && is_null($element->getAttribute('checked'))) ||
(!$bSetChecked && !is_null($element->getAttribute('checked')))) {
$element->click();
}
}
protected function check($locator)
{
$this->setCheckBoxValue($locator, true);
}
protected function unCheck($locator)
{
$this->setCheckBoxValue($locator, false);
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddPhenotypeInfoToIVAIndividualTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddPhenotypeInfoToIVAIndividualTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddPhenotypeInfoToIVAIndividual()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000002$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/phenotypes[\s\S]create&target=00000002$/', $this->getLocation()));
$this->type("name=Phenotype/Additional", "additional information");
$this->select("name=Phenotype/Inheritance", "label=Familial");
$this->select("name=owned_by", "label=LOVD3 Admin (#00001)");
$this->select("name=statusid", "label=Public");
$this->click("//input[@value='Create phenotype information entry']");
$this->waitForPageToLoad("30000");
$this->assertEquals("Successfully created the phenotype entry!", $this->getText("css=table[class=info]"));
$this->waitForPageToLoad("4000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000002$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/phenotypes[\s\S]create&target=00000002$/', $this->driver->getCurrentURL()));
$this->enterValue(WebDriverBy::name("Phenotype/Additional"), "additional information");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Phenotype/Inheritance"]/option[text()="Familial"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin (#00001)"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="statusid"]/option[text()="Public"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Create phenotype information entry']"));
$element->click();
$this->assertEquals("Successfully created the phenotype entry!", $this->driver->findElement(WebDriverBy::cssSelector("table[class=info]"))->getText());
$element->click();
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddPhenotypeInfoToHealthyIndividualTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddPhenotypeInfoToHealthyIndividualTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddPhenotypeInfoToHealthyIndividual()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000001$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/phenotypes[\s\S]create&target=00000001$/', $this->getLocation()));
$this->selectWindow("null");
$this->type("name=Phenotype/Age", "35y");
$this->select("name=owned_by", "label=LOVD3 Admin (#00001)");
$this->select("name=statusid", "label=Public");
$this->click("//input[@value='Create phenotype information entry']");
$this->waitForPageToLoad("30000");
$this->assertEquals("Successfully created the phenotype entry!", $this->getText("css=table[class=info]"));
$this->waitForPageToLoad("4000");
// wait for page redirect
$this->waitUntil(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b")));
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000001$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/phenotypes[\s\S]create&target=00000001$/', $this->driver->getCurrentURL()));
// $this->selectWindow("null");
$this->enterValue(WebDriverBy::name("Phenotype/Age"), "35y");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin (#00001)"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="statusid"]/option[text()="Public"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Create phenotype information entry']"));
$element->click();
$this->assertEquals("Successfully created the phenotype entry!", $this->driver->findElement(WebDriverBy::cssSelector("table[class=info]"))->getText());
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddScreeningToIVAIndividualTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddScreeningToIVAIndividualTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddScreeningToIVAIndividual()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000002$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/screenings[\s\S]create&target=00000002$/', $this->getLocation()));
$this->addSelection("name=Screening/Template[]", "label=RNA (cDNA)");
$this->addSelection("name=Screening/Template[]", "label=Protein");
$this->addSelection("name=Screening/Technique[]", "label=array for Comparative Genomic Hybridisation");
$this->addSelection("name=Screening/Technique[]", "label=array for resequencing");
$this->addSelection("name=Screening/Technique[]", "label=array for SNP typing");
$this->addSelection("name=genes[]", "label=IVD (isovaleryl-CoA dehydrogenase)");
$this->check("name=variants_found");
$this->select("name=owned_by", "label=LOVD3 Admin (#00001)");
$this->click("//input[@value='Create screening information entry']");
$this->waitForPageToLoad("30000");
$this->assertEquals("Successfully created the screening entry!", $this->getText("css=table[class=info]"));
$this->waitForPageToLoad("4000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000002$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/screenings[\s\S]create&target=00000002$/', $this->driver->getCurrentURL()));
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Template[]"]/option[text()="RNA (cDNA)"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Template[]"]/option[text()="Protein"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for Comparative Genomic Hybridisation"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for resequencing"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for SNP typing"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="genes[]"]/option[text()="IVD (isovaleryl-CoA dehydrogenase)"]'));
$option->click();
$this->check(WebDriverBy::name("variants_found"));
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin (#00001)"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Create screening information entry']"));
$element->click();
$this->assertEquals("Successfully created the screening entry!", $this->driver->findElement(WebDriverBy::cssSelector("table[class=info]"))->getText());
$element->click();
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddScreeningToHealthyIndividualTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddScreeningToHealthyIndividualTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddScreeningToHealthyIndividual()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000001$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/screenings[\s\S]create&target=00000001$/', $this->getLocation()));
$this->addSelection("name=Screening/Template[]", "label=RNA (cDNA)");
$this->addSelection("name=Screening/Template[]", "label=Protein");
$this->addSelection("name=Screening/Technique[]", "label=array for Comparative Genomic Hybridisation");
$this->addSelection("name=Screening/Technique[]", "label=array for resequencing");
$this->addSelection("name=Screening/Technique[]", "label=array for SNP typing");
$this->addSelection("name=genes[]", "label=IVD (isovaleryl-CoA dehydrogenase)");
$this->check("name=variants_found");
$this->select("name=owned_by", "label=LOVD3 Admin (#00001)");
$this->click("//input[@value='Create screening information entry']");
$this->waitForPageToLoad("30000");
$this->assertEquals("Successfully created the screening entry!", $this->getText("css=table[class=info]"));
$this->waitForPageToLoad("4000");
// wait for page redirect
$this->waitUntil(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b")));
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/individual\/00000001$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/screenings[\s\S]create&target=00000001$/', $this->driver->getCurrentURL()));
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Template[]"]/option[text()="RNA (cDNA)"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Template[]"]/option[text()="Protein"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for Comparative Genomic Hybridisation"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for resequencing"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="Screening/Technique[]"]/option[text()="array for SNP typing"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="genes[]"]/option[text()="IVD (isovaleryl-CoA dehydrogenase)"]'));
$option->click();
$this->check(WebDriverBy::name("variants_found"));
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin (#00001)"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Create screening information entry']"));
$element->click();
$this->assertEquals("Successfully created the screening entry!", $this->driver->findElement(WebDriverBy::cssSelector("table[class=info]"))->getText());
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddSeattleseqFileToHealthyIndividualTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddSeattleseqFileToHealthyIndividualTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddSeattleseqFileToHealthyIndividual()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/screening\/0000000001$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr/td[2]");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create&target=0000000001$/', $this->getLocation()));
$this->click("//tr[3]/td[2]");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/upload[\s\S]create&target=0000000001$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/upload[\s\S]create&type=SeattleSeq&target=0000000001$/', $this->getLocation()));
$this->type("name=variant_file", ROOT_PATH . "/tests/test_data_files/ShortSeattleSeqAnnotation138v1.txt");
$this->select("name=hg_build", "label=hg19");
$this->select("name=dbSNP_column", "label=VariantOnGenome/Reference");
$this->select("name=autocreate", "label=Create genes and transcripts");
$this->select("name=owned_by", "label=LOVD3 Admin");
$this->select("name=statusid", "label=Public");
$this->click("//input[@value='Upload SeattleSeq file']");
// wait for page redirect
$this->waitUntil(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]")));
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit\/screening\/0000000001$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create&target=0000000001$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//tr[3]/td[2]"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/upload[\s\S]create&target=0000000001$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/upload[\s\S]create&type=SeattleSeq&target=0000000001$/', $this->driver->getCurrentURL()));
$this->enterValue(WebDriverBy::name("variant_file"), ROOT_PATH . "/tests/test_data_files/ShortSeattleSeqAnnotation138v1.txt");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="hg_build"]/option[text()="hg19"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="dbSNP_column"]/option[text()="VariantOnGenome/Reference"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="autocreate"]/option[text()="Create genes and transcripts"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="statusid"]/option[text()="Public"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Upload SeattleSeq file']"));
for ($second = 0; ; $second++) {
if ($second >= 300) $this->fail("timeout");
try {
if ($this->isElementPresent("//input[@value='Continue »']")) break;
if ($this->isElementPresent(WebDriverBy::xpath("//input[@value='Continue »']"))) break;
} catch (Exception $e) {
}
sleep(1);
}
$this->assertEquals("138 variants were imported, 1 variant could not be imported.", $this->getText("id=lovd__progress_message"));
$this->click("//input[@value='Continue »']");
$this->waitForPageToLoad("30000");
$this->assertEquals("138 variants were imported, 1 variant could not be imported.", $this->driver->findElement(WebDriverBy::id("lovd__progress_message"))->getText());
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Continue »']"));
$element->click();
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddSummaryVariantLocatedWithinGeneTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddSummaryVariantLocatedWithinGeneTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddSummaryVariantLocatedWithinGene()
{
$this->click("link=Submit new data");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit$/', $this->getLocation()));
$element = $this->driver->findElement(WebDriverBy::linkText("Submit new data"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit$/', $this->driver->getCurrentURL()));
$this->chooseOkOnNextConfirmation();
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*Please reconsider to submit individual data as well, as it makes the data you submit much more valuable![\s\S]*$/', $this->getConfirmation()));
sleep(4);
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b");
$this->click("//tr[@id='ARSD']/td[2]");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create&reference=Transcript&geneid=ARSD$/', $this->getLocation()));
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr/td[2]/b"));
$element->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//tr[@id='ARSD']/td[2]"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create&reference=Transcript&geneid=ARSD$/', $this->driver->getCurrentURL()));
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
try {
if ($this->isElementPresent("name=ignore_00000002")) break;
if ($this->isElementPresent(WebDriverBy::name("ignore_00000002"))) break;
} catch (Exception $e) {
}
sleep(1);
}
$this->uncheck("name=ignore_00000002");
$this->uncheck("name=ignore_00000003");
$this->type("name=00000002_VariantOnTranscript/Exon", "3");
$this->type("name=00000003_VariantOnTranscript/Exon", "3");
$this->type("name=00000002_VariantOnTranscript/DNA", "c.62T>C");
$this->click("css=button.mapVariant");
$this->uncheck(WebDriverBy::name("ignore_00000002"));
$this->uncheck(WebDriverBy::name("ignore_00000003"));
$this->enterValue(WebDriverBy::name("00000002_VariantOnTranscript/Exon"), "3");
$this->enterValue(WebDriverBy::name("00000003_VariantOnTranscript/Exon"), "3");
$this->enterValue(WebDriverBy::name("00000002_VariantOnTranscript/DNA"), "c.62T>C");
$element = $this->driver->findElement(WebDriverBy::cssSelector("button.mapVariant"));
$element->click();
sleep(3);
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
try {
if ($this->isElementPresent("css=img[alt=\"Prediction OK!\"]")) break;
if ($this->isElementPresent(WebDriverBy::cssSelector("img[alt='Prediction OK!']"))) break;
} catch (Exception $e) {
}
sleep(1);
......@@ -44,34 +50,44 @@ class AddSummaryVariantLocatedWithinGeneTest extends LOVDSeleniumBaseTestCase
$this->assertTrue((bool)preg_match('/^r\.\([\s\S]\)$/', $this->getExpression($RnaChange)));
$ProteinChange = $this->getEval("window.document.getElementById('variantForm').elements[5].value");
$this->assertEquals("p.(Leu21Pro)", $this->getExpression($ProteinChange));
$this->select("name=00000002_effect_reported", "label=Probably affects function");
$this->select("name=00000002_effect_concluded", "label=Probably does not affect function");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="00000002_effect_reported"]/option[text()="Probably affects function"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="00000002_effect_concluded"]/option[text()="Probably does not affect function"]'));
$option->click();
$RnaChangeTwo = $this->getEval("window.document.getElementById('variantForm').elements[4].value");
$this->assertTrue((bool)preg_match('/^r\.\([\s\S]\)$/', $this->getExpression($RnaChangeTwo)));
$ProteinChangeTwo = $this->getEval("window.document.getElementById('variantForm').elements[5].value");
$this->assertEquals("p.(Leu21Pro)", $this->getExpression($ProteinChangeTwo));
$this->select("name=00000003_effect_reported", "label=Probably affects function");
$this->select("name=00000003_effect_concluded", "label=Probably does not affect function");
$this->select("name=allele", "label=Maternal (confirmed)");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="00000003_effect_reported"]/option[text()="Probably affects function"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="00000003_effect_concluded"]/option[text()="Probably does not affect function"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="allele"]/option[text()="Maternal (confirmed)"]'));
$option->click();
$GenomicDnaChange = $this->getEval("window.document.getElementById('variantForm').elements[19].value");
$this->assertEquals("g.2843789A>G", $this->getExpression($GenomicDnaChange));
$this->click("link=PubMed");
$this->type("name=VariantOnGenome/Reference", "{PMID:[2011]:[2150333]}");
$this->type("name=VariantOnGenome/Frequency", "55/18000");
$this->select("name=effect_reported", "label=Affects function");
$this->select("name=effect_concluded", "label=Affects function");
$this->select("name=owned_by", "label=LOVD3 Admin (#00001)");
$this->select("name=statusid", "label=Public");
$this->click("//input[@value='Create variant entry']");
$element = $this->driver->findElement(WebDriverBy::linkText("PubMed"));
$element->click();
$this->enterValue(WebDriverBy::name("VariantOnGenome/Reference"), "{PMID:[2011]:[2150333]}");
$this->enterValue(WebDriverBy::name("VariantOnGenome/Frequency"), "55/18000");
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="effect_reported"]/option[text()="Affects function"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="effect_concluded"]/option[text()="Affects function"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="owned_by"]/option[text()="LOVD3 Admin (#00001)"]'));
$option->click();
$option = $this->driver->findElement(WebDriverBy::xpath('//select[@name="statusid"]/option[text()="Public"]'));
$option->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Create variant entry']"));
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
if ($this->isElementPresent("css=table[class=info]")) {
$this->assertContains("Successfully processed your submission and sent an email notification to the relevant curator", $this->getText("css=table[class=info]"));
if ($this->isElementPresent(WebDriverBy::cssSelector("table[class=info]"))) {
$this->assertContains("Successfully processed your submission and sent an email notification to the relevant curator", $this->driver->findElement(WebDriverBy::cssSelector("table[class=info]"))->getText());
break;
}
sleep(1);
}
$this->waitForPageToLoad("4000");
$this->assertContains("src/variants/0000000168", $this->getLocation());
$element->click();
$this->assertContains("src/variants/0000000168", $this->driver->getCurrentURL());
}
}
<?php
require_once 'LOVDSeleniumBaseTestCase.php';
class AddSummaryVariantOnlyDescribedOnGenomicLevelTest extends LOVDSeleniumBaseTestCase
use \Facebook\WebDriver\WebDriverBy;
use \Facebook\WebDriver\WebDriverExpectedCondition;
class AddSummaryVariantOnlyDescribedOnGenomicLevelTest extends LOVDSeleniumWebdriverBaseTestCase
{
public function testAddSummaryVariantOnlyDescribedOnGenomicLevel()
{
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/0000000168$/', $this->getLocation()));
$this->click("link=Submit new data");
$this->waitForPageToLoad("30000");
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit$/', $this->getLocation()));
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants\/0000000168$/', $this->driver->getCurrentURL()));
$element = $this->driver->findElement(WebDriverBy::linkText("Submit new data"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/submit$/', $this->driver->getCurrentURL()));
$this->chooseOkOnNextConfirmation();
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$element = $this->driver->findElement(WebDriverBy::xpath("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b"));
$element->click();
$this->assertTrue((bool)preg_match('/^[\s\S]*Please reconsider to submit individual data as well, as it makes the data you submit much more valuable![\s\S]*$/', $this->getConfirmation()));
sleep(4);
$this->assertTrue((bool)preg_match('/^[\s\S]*\/src\/variants[\s\S]create$/', $this->getLocation()));
$this->click("//div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/b");
$this->waitForPageToLoad("30000");
$this->open(ROOT_URL . "/src/variants?create&reference=Genome");
$this->select("name=allele", "label=Paternal (confirmed)");
$this->select("name=chromosome", "label=15");
$this->type("name=VariantOnGenome/DNA", "g.40702976G>T");
$this->click("link=PubMed");
$this->type("name=VariantOnGenome/Reference", "{PMID:[2011]:[21520333]}");
$this->type("name=VariantOnGenome/Frequency", "11/10000");