def runTooltipTest(driver, target): print('Start tooltip tests') htmlHeaderCss = 'htmlpopup-header' htmlContainerCss = 'htmlpopup-container' topToolsId = 'toptools' wait = WebDriverWait(driver, 10) for tooltipTest in tooltipTests: permalink = tooltipTest['permalink'] url = '%s%s' % (target, permalink) pageLoadWait(driver, url) viewport = driver.find_element_by_css_selector('.ol-viewport') # Click on map and open the tooltip action = ActionChains(driver) # Move to the center of viewport action.move_to_element(viewport) action.click() action.perform() # Wait until at least the first result wait.until( EC.visibility_of_element_located( (By.CLASS_NAME, htmlContainerCss))) htmlContainerEl = driver.find_element_by_css_selector('.%s' % htmlContainerCss) assert u'BFS-Nummer' in htmlContainerEl.text, htmlContainerEl.text assert u'Name' in htmlContainerEl.text, htmlContainerEl.text assert u'Fläche' in htmlContainerEl.text, htmlContainerEl.text assert u'Perimeter' in htmlContainerEl.text, htmlContainerEl.text # Change language to fr fr = driver.find_element_by_css_selector('#%s div div :nth-child(2)' % topToolsId) action = ActionChains(driver) action.move_to_element(fr) action.click() action.perform() wait.until( EC.text_to_be_present_in_element( (By.CSS_SELECTOR, 'div.%s > span' % htmlHeaderCss), u'limites')) htmlContainerEl = driver.find_element_by_css_selector('.%s' % htmlContainerCss) assert u'Numéro OFS' in htmlContainerEl.text, htmlContainerEl.text assert u'Nom' in htmlContainerEl.text, htmlContainerEl.text assert u'Surface' in htmlContainerEl.text, htmlContainerEl.text assert u'Périmètre' in htmlContainerEl.text, htmlContainerEl.text
def runMobileTest(driver, target, is_top_browser): print "Start Mobile tests" target_url = target + '?lang=de' driver.get(target_url) pageLoadWait(driver, target_url) current_url = driver.current_url # Switch to Mobile Version driver.find_element_by_link_text("Mobile Version").click() try: waitForUrlChange(driver, current_url) # Rem : mobile.html is replace by index.tml except Exception as e: print '-----------' print str(e) print "Current url: " + current_url raise Exception("Mobile version not loaded !") # Zoom-in driver.find_element_by_css_selector("button.ol-zoom-in").click() if waitForUrlChange(driver, QUERYSTRING_WHEN_ZOOM_IN): print 'Mobile: expected pattern %s was not found after a zoom in' % QUERYSTRING_WHEN_ZOOM_IN sys.exit(1) # Make a search driver.find_element_by_xpath("//input[@type='search']").clear() driver.find_element_by_xpath("//input[@type='search']").send_keys( "Avenches") driver.find_element_by_css_selector("span.ga-search-highlight").click() if waitForUrlChange(driver, QUERYSTRING_OF_AVENCHES): print 'Mobile: expected pattern %s was not found after a search' % QUERYSTRING_OF_AVENCHES sys.exit(1) # Check result search of 'wasser'. Must return locations (Gehe nach) and # layers (Karte hinzufügen) driver.find_element_by_xpath("//input[@type='search']").clear() driver.find_element_by_xpath("//*[@type='search']").send_keys("wasser") # Check if result contain data and layer driver.find_element_by_xpath("//*[contains(text(), 'Gehe nach')]") driver.find_element_by_xpath("//*[contains(text(), 'Karte hinzufügen')]") print "Mobile tests Ok !"
def runSearchTest(driver, target): print 'Start Search tests' # swissearch parameter with multiple results targetUrl = target + '?lang=de' driver.get(targetUrl) pageLoadWait(driver, targetUrl) # Test interactions with input element, dropdown list, clear btn etc.. inputSearchEl = driver.find_element_by_class_name(inputClass) for searchTest in searchLocationTests: testSearchLocationInput(driver, inputSearchEl, searchTest) for searchTest in searchLayerTests: testSearchLayerInput(driver, inputSearchEl, searchTest) # Test swissearch parameter in permalink for swissSearchTest in swissSearchParamTests: testSwissSearchParameter(driver, target, inputSearchEl, swissSearchTest)
def runTooltipTest(driver, target): print('Start tooltip tests') htmlHeaderCss = 'htmlpopup-header' htmlContainerCss = 'htmlpopup-container' topToolsId = 'toptools' wait = WebDriverWait(driver, 10) for tooltipTest in tooltipTests: permalink = tooltipTest['permalink'] url = '%s%s' % (target, permalink) pageLoadWait(driver, url) viewport = driver.find_element_by_css_selector('.ol-viewport') # Click on map and open the tooltip action = ActionChains(driver) # Move to the center of viewport action.move_to_element(viewport) action.click() action.perform() # Wait until at least the first result wait.until( EC.visibility_of_element_located((By.CLASS_NAME, htmlContainerCss))) htmlContainerEl = driver.find_element_by_css_selector('.%s' % htmlContainerCss) assert u'BFS-Nummer' in htmlContainerEl.text, htmlContainerEl.text assert u'Name' in htmlContainerEl.text, htmlContainerEl.text assert u'Fläche' in htmlContainerEl.text, htmlContainerEl.text assert u'Perimeter' in htmlContainerEl.text, htmlContainerEl.text # Change language to fr fr = driver.find_element_by_css_selector('#%s div div :nth-child(2)' % topToolsId) action = ActionChains(driver) action.move_to_element(fr) action.click() action.perform() wait.until( EC.text_to_be_present_in_element((By.CSS_SELECTOR, 'div.%s > span' % htmlHeaderCss), u'limites')) htmlContainerEl = driver.find_element_by_css_selector('.%s' % htmlContainerCss) assert u'Numéro OFS' in htmlContainerEl.text, htmlContainerEl.text assert u'Nom' in htmlContainerEl.text, htmlContainerEl.text assert u'Surface' in htmlContainerEl.text, htmlContainerEl.text assert u'Périmètre' in htmlContainerEl.text, htmlContainerEl.text
def runSearchTest(driver, target, is_top_browser): print 'Start Search tests' # swissearch parameter with multiple results targetUrl = target + '?lang=de' driver.get(targetUrl) pageLoadWait(driver, targetUrl) # Test interactions with input element, dropdown list, clear btn etc.. inputSearchEl = driver.find_element_by_class_name(inputClass) for searchTest in searchLocationTests: testSearchLocationInput(driver, inputSearchEl, searchTest) for searchTest in searchLayerTests: testSearchLayerInput(driver, inputSearchEl, searchTest) # Test swissearch parameter in permalink for swissSearchTest in swissSearchParamTests: testSwissSearchParameter(driver, target, inputSearchEl, swissSearchTest)