本文整理汇总了Python中splinter.Browser.find_link_by_href方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.find_link_by_href方法的具体用法?Python Browser.find_link_by_href怎么用?Python Browser.find_link_by_href使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splinter.Browser
的用法示例。
在下文中一共展示了Browser.find_link_by_href方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getRoutes
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
def getRoutes(start,end):
browser = Browser(
driver_name="firefox"
)
browser.visit('https://www.hopstop.com/search?xfr=cityscape')
print(browser.url)
browser.fill('address1',str(start))
browser.fill('address2',str(end))
browser.find_by_name('get_dirs').click()
print(browser.url)
if browser.is_text_present('Did you mean?'):
print "better at least get here"
#browser.click_link_by_href("#")
for link in browser.find_link_by_href("#"):
print "Okay"
if link.visible == True:
print link.text
browser.click_link_by_text(link.text)
break
browser.click_link_by_href("#")
links = browser.find_link_by_partial_href("/station?stid")
results = []
for link in links:
results.append(link.value)
browser.quit()
return results
示例2: test_fail
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
def test_fail(self):
browser = Browser("firefox", extensions=["adblock.xpi"])
browser.visit("http://kinox.to/Stream/The_Big_Bang_Theory.html")
sleep(5)
result = browser.find_link_by_href("http://streamcloud.eu/")
browser.quit()
assert not result
示例3: test_choose_stream_cloud
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
def test_choose_stream_cloud(self):
browser = Browser("firefox", extensions=["adblock.xpi"])
browser.visit("http://kinox.to/Stream/The_Big_Bang_Theory.html")
stream = script.watchSeries("http://kinox.to/Stream/The_Big_Bang_Theory.html", None)
sleep(5)
stream.choose_stream_cloud(browser)
sleep(5)
result = browser.find_link_by_href("http://streamcloud.eu/")
browser.quit()
assert result
示例4: __authorize
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
def __authorize(self):
b = Browser('chrome')
b.visit("http://box-token-generator.herokuapp.com/")
if b.find_link_by_href('set_client_credentials'):
b.visit('http://box-token-generator.herokuapp.com/set_client_credentials')
time.sleep(2)
b.find_by_id('login').first.fill('[email protected]')
b.find_by_id('password').first.fill('dharit1250')
b.find_by_name('login_submit').first.click()
b.find_by_id('consent_accept_button').first.click()
code = b.find_by_tag('h4')[1].text
self.client = box.BoxClient(code)
b.quit()
示例5: test_choose_stream_cloud_hidden
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
def test_choose_stream_cloud_hidden(self):
browser = Browser("firefox", extensions=["adblock.xpi"])
browser.visit("http://kinox.to/Stream/The_Big_Bang_Theory.html")
sleep(2)
overview_present = browser.is_element_present_by_id("ClickHelper", 5)
if overview_present:
overview_button = browser.find_by_id("ClickHelper")
overview_button.click()
overview_button.click()
stream = script.watchSeries("http://kinox.to/Stream/The_Big_Bang_Theory.html", None)
sleep(10)
stream.choose_stream_cloud(browser)
sleep(5)
result = browser.find_link_by_href("http://streamcloud.eu/")
assert result
else:
print "Test went wrong."
assert False
browser.quit()
示例6: CollaboratorTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class CollaboratorTestCase(LiveServerTestCase):
"""
These tests check the permissions system creating two users: one creates a
graph and gives permissions to the other, the other tests the permissions
given.
On these tests, is the developer who must keep the logic of the
permissions. If he/she wants to give any permission to an user he/she must
first creates the usar and then creates the collaboration adding the basic
perrmission: 'chk_graph_view_graph'.
The name of the tests self-explain the behaviour of them.
"""
def setUp(self):
self.browser = Browser()
def tearDown(self):
logout(self)
self.browser.quit()
def test_graph_view_without_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.visit(self.live_server_url + '/graphs/bobs-graph/')
text = self.browser.find_by_xpath(
"//div[@class='heading']/h1").first.value
self.assertNotEqual(text.find("403"), -1)
Graph.objects.get(name="Bob's graph").destroy()
def test_graph_view_with_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
add_permission(self, 'alice', CREATE_COLLAB)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
text = self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.value
self.assertEqual(text, "Bob's graph")
Graph.objects.get(name="Bob's graph").destroy()
def test_graph_change_without_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
add_permission(self, 'alice', CREATE_COLLAB)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.click()
text = self.browser.find_by_xpath(
"//div[@class='heading']/h1").first.value
self.assertNotEqual(text.find("403"), -1)
Graph.objects.get(name="Bob's graph").destroy()
def test_graph_change_with_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
add_permission(self, 'alice', CREATE_COLLAB)
add_permission(self, 'alice', GRAPH_CHANGE)
logout(self)
signin(self, 'alice', 'alice_secret')
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.click()
self.browser.find_by_xpath(
"//input[@id='id_name']").first.fill("Alice's graph")
self.browser.find_by_xpath(
"//form/input[@type='submit']").first.click()
text = self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.value
self.assertEqual(text, "Alice's graph")
Graph.objects.get(name="Alice's graph").destroy()
def test_schema_view_without_permissions(self):
signup(self, 'alice', '[email protected]', 'alice_secret')
signin(self, 'alice', 'alice_secret')
logout(self)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
create_graph(self)
create_schema(self)
create_type(self)
add_permission(self, 'alice', CREATE_COLLAB)
#.........这里部分代码省略.........
示例7: UserTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
#.........这里部分代码省略.........
self.assertEqual(text, 'Please enter a correct username or email and password. Note that both fields are case-sensitive.')
def test_user_signin_empty_password(self):
signup(self, 'bob', '[email protected]', 'bob_secret')
self.browser.visit(self.live_server_url + '/accounts/signin/')
self.browser.find_by_name('identification').fill('bob')
self.browser.find_by_name('password').fill('')
self.browser.find_by_xpath(
"//div[@id='body']/div/form/input").first.click()
text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
self.assertEqual(text, 'This field is required.')
def test_user_signin_bad_password(self):
signup(self, 'bob', '[email protected]', 'bob_secret')
self.browser.visit(self.live_server_url + '/accounts/signin/')
self.browser.find_by_name('identification').fill('bob')
self.browser.find_by_name('password').fill('alice_secret')
self.browser.find_by_xpath(
"//div[@id='body']/div/form/input").first.click()
text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
self.assertEqual(text, 'Please enter a correct username or email and password. Note that both fields are case-sensitive.')
def test_user_logout(self):
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
logout(self)
self.assertEqual(self.browser.title, 'SylvaDB - Signed out')
self.assertEqual(self.browser.find_by_css('.body-inside').first.value, 'You have been signed out. Till we meet again.')
def test_user_details(self):
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
self.assertEqual(self.browser.title, 'SylvaDB - Dashboard')
self.browser.find_link_by_href('/accounts/bob/').first.click()
self.assertEqual(self.browser.title, 'SylvaDB - bob\'s profile.')
self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
self.assertEqual(self.browser.title, 'SylvaDB - Account setup')
self.browser.find_by_name('first_name').fill('Bob')
self.browser.find_by_name('last_name').fill('Doe')
self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
self.browser.select('language', 'en')
self.browser.select('gender', '1')
self.browser.find_by_name('website').fill('http://www.bobweb.com')
self.browser.find_by_name('location').fill('London, Ontario')
self.browser.find_by_name('birth_date').fill('01/01/1975')
self.browser.find_by_name('about_me').fill('I am a very nice guy')
self.browser.find_by_name('institution').fill('University')
self.browser.find_by_name('company').fill('CulturePlex')
self.browser.find_by_name('lab').fill('CulturePlex')
self.browser.find_by_value('Save changes').first.click()
self.assertEqual(self.browser.title, 'SylvaDB - bob\'s profile.')
logout(self)
def test_user_details_bad_website(self):
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
self.assertEqual(self.browser.title, 'SylvaDB - Dashboard')
self.browser.find_link_by_href('/accounts/bob/').first.click()
self.assertEqual(self.browser.title, 'SylvaDB - bob\'s profile.')
self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
self.assertEqual(self.browser.title, 'SylvaDB - Account setup')
self.browser.find_by_name('first_name').fill('Bob')
self.browser.find_by_name('last_name').fill('Doe')
self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
self.browser.select('language', 'en')
self.browser.select('gender', '1')
示例8: DataNodeTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class DataNodeTestCase(LiveServerTestCase):
"""
A set of tests to test all interaction related to the creation and
deletion of nodes and relationships. Also, we test export the data in two
formats: gexf and csv.
"""
def setUp(self):
self.browser = Browser()
socket.setdefaulttimeout(30)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
def tearDown(self):
logout(self)
self.browser.quit()
@classmethod
def tearDownClass(cls):
sleep(10) # It needs some time for close the LiverServerTestCase
super(DataNodeTestCase, cls).tearDownClass()
def test_data_node_addition(self):
create_graph(self)
create_schema(self)
create_type(self)
create_data(self)
# Check the node name
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
text = self.browser.find_by_id('propertiesTitle').first.value
spin_assert(lambda: self.assertEqual(text, 'Properties'))
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a").first.click()
self.browser.choose('confirm', '1')
self.browser.find_by_value('Continue').first.click()
text = self.browser.find_by_xpath("//div[@class='indent']/div").first.value
Graph.objects.get(name="Bob's graph").destroy()
spin_assert(lambda: self.assertEqual(text, 'Nodes: 0'))
def test_data_node_addition_rel_add_del(self):
create_graph(self)
create_schema(self)
create_type(self)
create_node(self, "Bob")
create_node(self, "Alice")
# We create a allowed relation
js_code = "$('a#schema-link')[0].click();"
self.browser.execute_script(js_code)
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill("Bob's rel")
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill("This the allowed relationship for Bob's graph")
self.browser.find_by_value('Save Type').first.click()
spin_assert(lambda: self.assertEqual(
self.browser.title, "SylvaDB - Bob's graph"))
# We create the link between the nodes
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
self.browser.is_element_present_by_id("id_user_wait", 5)
self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
# Delete the relationship
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//span[@class='all-relationships incoming-relationships i_bobs_rel1-relationships']//a[@class='delete-row initial-form floating']").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
spin_assert(lambda: self.assertEqual(text, "0 relationships"))
Graph.objects.get(name="Bob's graph").destroy()
def test_node_type_deletion_keeping_nodes(self):
create_graph(self)
create_schema(self)
create_type(self)
# Adding relationship to the type
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill("Bob's rel")
self.browser.select('target', '1')
self.browser.find_by_id('id_description').fill(
'The loved relationship')
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_xpath(
"//div[@class='form-row indent']/label").first.value
spin_assert(lambda: self.assertNotEqual(text.find("Bob's rel"), -1))
# Creating nodes
create_node(self, 'Bob')
create_node(self, 'Alice')
# Creating relationship between nodes
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
self.browser.is_element_present_by_id("id_user_wait", wait_time=5)
self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
self.browser.find_by_value("Save Bob's type").first.click()
self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
#.........这里部分代码省略.........
示例9: SchemaTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class SchemaTestCase(LiveServerTestCase):
"""
A set of tests for testing export schema, import schema and everything
related to advanced types (patterns, options, etc.).
"""
def setUp(self):
self.browser = Browser()
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
def tearDown(self):
logout(self)
self.browser.quit()
def test_export_schema(self):
create_graph(self)
create_schema(self)
create_type(self)
self.browser.find_by_id('toolsMenu').first.click()
cookies = {self.browser.cookies.all()[0]["name"]: self.browser.cookies.all()[0]["value"], self.browser.cookies.all()[1]["name"]: self.browser.cookies.all()[1]["value"]}
result = requests.get(self.live_server_url + '/schemas/bobs-graph/export/', cookies=cookies)
self.assertEqual(result.headers['content-type'], 'application/json')
self.assertEqual(self.browser.status_code.is_success(), True)
f = open('sylva/base/tests/files/bobs-graph_schema.json')
self.assertEqual(f.read().split("\n")[0], result.content)
def test_import_schema(self):
create_graph(self)
create_schema(self)
self.browser.find_by_id('schemaImport').first.click()
file_path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'files/bobs-graph_schema.json'
)
self.browser.attach_file('file', file_path)
self.browser.find_by_value('Continue').first.click()
self.assertEqual(self.browser.title, "SylvaDB - Bob's graph")
text = self.browser.find_by_id('diagramBoxField_bobs-graph.bobs-type.undefined').first.value
self.assertEqual(text, "Name")
def test_new_type(self):
create_graph(self)
create_schema(self)
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
text = self.browser.find_by_xpath(
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_xpath(
"//div[@class='content2-first']/p/textarea[@name='description']").first.fill('The loved type')
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_xpath(
"//div[@id='diagramBox_bobs-type']/div[@class='title']").first.value
self.assertNotEqual(text.find("Bob's type"), -1)
def test_new_advanced_type(self):
create_graph(self)
create_schema(self)
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
text = self.browser.find_by_xpath(
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_id('advancedModeButton').first.click()
self.browser.find_by_name('properties-0-key').first.fill('Name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_name('properties-0-required').first.check()
self.browser.find_by_name('properties-0-default').first.fill(
"Bob's node default name")
self.browser.find_by_name('properties-0-order').first.fill('1')
self.browser.find_by_name('properties-0-description').first.fill(
"The name of this Bob's node")
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_id(
'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
self.assertEqual(text, "Name")
def test_new_advanced_type_string_empty(self):
create_graph(self)
create_schema(self)
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
text = self.browser.find_by_xpath(
"//div[@class='content2-first']/h2").first.value
self.assertEqual(text, 'Type')
self.browser.find_by_name('name').first.fill("Bob's type")
self.browser.find_by_id('advancedModeButton').first.click()
self.browser.find_by_name('properties-0-key').first.fill('String name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_name('properties-0-required').first.check()
self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='s']").first.click()
self.browser.find_by_name('properties-0-order').first.fill('1')
self.browser.find_by_name('properties-0-description').first.fill(
"The name of this Bob's node")
self.browser.find_by_value('Save Type').first.click()
text = self.browser.find_by_id(
'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
#.........这里部分代码省略.........
示例10: ToolsTestCaseCsv
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class ToolsTestCaseCsv(LiveServerTestCase):
"""
A master test to check the behaviour of the new 'auto' fields.
Actually only works with gephi format.
"""
def setUp(self):
self.browser = Browser()
socket.setdefaulttimeout(30)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
self.firstGraphName = "bobgraph"
self.secondGraphName = "alicegraph"
def tearDown(self):
logout(self)
self.browser.quit()
@classmethod
def tearDownClass(cls):
sleep(10) # It needs some time for close the LiverServerTestCase
super(ToolsTestCaseCsv, cls).tearDownClass()
def test_graph_export_csv(self):
# Create a graph with a auto_user property
create_graph(self, self.firstGraphName)
create_advanced_schema(self, self.firstGraphName)
create_advanced_type(self, self.firstGraphName, "e")
create_advanced_data(self)
# Create new graph for import the data
import_advanced_schema_csv(self, self.firstGraphName, self.secondGraphName)
# Data import
self.browser.find_by_id('toolsMenu').first.click()
self.browser.find_link_by_href('/tools/' + self.secondGraphName + '/import/').first.click()
self.browser.find_by_id('csv-radio').first.click()
# Change the display field of input to attach the file
script = """
$('#files').css('display', '');
"""
self.browser.execute_script(script)
self.browser.is_text_present('Drop your nodes files here', wait_time=10)
# Import the nodes
file_path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'files/csv/bobs-type.csv'
)
self.browser.attach_file('file', file_path)
self.browser.is_text_present('Nodes files loaded. Loading edges files...', wait_time=10)
# Wait until the data is imported
self.browser.is_text_present('Now drop your edges files', wait_time=10)
# Change the display field of input to attach the file
script = """
$('#files2').css('display', '');
"""
self.browser.execute_script(script)
# Import the relationships
file_path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'files/csv/bobs-rels.csv'
)
self.browser.attach_file('file2', file_path)
self.browser.is_text_present('Data loaded. Uploading to the server...', wait_time=10)
# Wait until the data is imported
self.browser.is_text_present('Data uploaded.', wait_time=10)
# Check that nodes and relationships are ok
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption list']").first.click()
alicegraph = Graph.objects.get(name=self.secondGraphName)
alicegraphNodes = alicegraph.nodes.count()
spin_assert(lambda: self.assertEqual(3, alicegraph.nodes.count()))
spin_assert(lambda: self.assertEqual(
1, alicegraph.relationships.count()))
# Add new nodes and relationships and check all is correct
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath(
"//a[@class='dataOption new']").first.click()
text = self.browser.find_by_id('propertiesTitle').first.value
spin_assert(lambda: self.assertEqual(text, 'Properties'))
self.browser.find_by_value("Save Bob's type").first.click()
text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
spin_assert(lambda: self.assertNotEqual(
text.find(" elements Bob's type."), -1))
spin_assert(lambda: self.assertEqual(
alicegraphNodes + 1, alicegraph.nodes.count()))
# Destroy the databases
Graph.objects.get(name=self.firstGraphName).destroy()
Graph.objects.get(name=self.secondGraphName).destroy()
示例11: len
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
if browser.title == "Logowanie do aplikacji WEBCLIP":
element = browser.find_by_name('login').first
element.value = "***"
element2 = browser.find_by_name('pass').first
element2.value = "***"
browser.find_by_value('Loguj').click()
if browser.title == "Logowanie do aplikacji WEBCLIP":
element = browser.find_by_name('login').first
element.value = "***"
element2 = browser.find_by_name('pass').first
element2.value = "***"
browser.find_by_value('Loguj').click()
if browser.title == "TYPOLOGIA":
links_found = browser.find_link_by_href('szukaj.php').click()
x = 0
lista_ids = []
not_found = []
exclude = []
while x < len(lista_spotow):
looked = lista_spotow[x]
if browser.title == "WYSZUKIWARKA":
element = browser.find_by_name('search_string').first
element.value = looked
element = browser.find_by_value('Szukaj').click()
print(browser.find_by_css('.ResultTable'))
if browser.find_by_css('.ResultTable'):
示例12: DashboardTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class DashboardTestCase(LiveServerTestCase):
"""
These tests check basic functions of Sylva's dashboard.
"""
def setUp(self):
self.browser = Browser()
socket.setdefaulttimeout(30)
signup(self, "bob", "[email protected]", "bob_secret")
def tearDown(self):
logout(self)
self.browser.quit()
@classmethod
def tearDownClass(cls):
sleep(10) # It needs some time for close the LiverServerTestCase
super(DashboardTestCase, cls).tearDownClass()
def test_dashboard(self):
signin(self, "bob", "bob_secret")
spin_assert(lambda: self.assertEquals(self.browser.title, "SylvaDB - Dashboard"))
text = self.browser.find_by_xpath("//header[@class='global']/h1").first.value
spin_assert(lambda: self.assertEqual(text, "Dashboard"))
def test_dashboard_new_graph(self):
signin(self, "bob", "bob_secret")
create_graph(self)
Graph.objects.get(name="Bob's graph").destroy()
def test_dashboard_graph_preview(self):
"""
This test, after create a graph with data, checks the Sigma
visualization running a simple JavaScript code. This code gets the
current instance of Sigma and checks the data with Sylva JavaScript
object.
"""
signin(self, "bob", "bob_secret")
create_graph(self)
create_schema(self)
create_type(self)
create_data(self)
self.browser.find_link_by_href("/graphs/bobs-graph/").first.click()
self.browser.is_element_present_by_id("wait_for_js", 3)
js_code = """
var instance = sigma.instances(0);
var node = instance.graph.nodes()[0];
sylva.test_node_name = node.properties.Name;
"""
self.browser.execute_script(js_code)
text = self.browser.evaluate_script("sylva.test_node_name")
Graph.objects.get(name="Bob's graph").destroy()
spin_assert(lambda: self.assertNotEqual(text.find("Bob's node"), -1))
def test_automatic_tour(self):
"""
Thist test checks that the tour starts automatically after signup, only
once.
"""
self.browser.is_element_present_by_id("wait_for_cookie_tour", 3)
signin(self, "bob", "bob_secret")
exist = self.browser.is_element_present_by_xpath("//div[@class='joyride-content-wrapper']")
spin_assert(lambda: self.assertEqual(exist, True))
self.browser.visit(self.live_server_url + "/dashboard/")
exist = self.browser.is_element_present_by_xpath("//div[@class='joyride-content-wrapper']")
spin_assert(lambda: self.assertNotEqual(exist, True))
示例13: BugTestCase
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class BugTestCase(LiveServerTestCase):
"""
A set of tests to check the existence of bugs.
"""
def setUp(self):
self.browser = Browser()
socket.setdefaulttimeout(30)
signup(self, 'bob', '[email protected]', 'bob_secret')
signin(self, 'bob', 'bob_secret')
def tearDown(self):
logout(self)
self.browser.quit()
Graph.objects.get(name="Bob's graph").destroy()
@classmethod
def tearDownClass(cls):
sleep(10) # It needs some time for close the LiverServerTestCase
super(BugTestCase, cls).tearDownClass()
def test_node_rel_count_one(self):
'''
This test show that reflexive outgoing `relationships` don't count if
there are more relationships.
'''
real_nodes = 0
real_rels = 0
create_graph(self)
create_schema(self)
# Creating a nodetype: "First"
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
self.browser.find_by_name('name').first.fill("First")
self.browser.find_by_name('properties-0-key').first.fill('Name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_value('Save Type').first.click()
# Creating another nodetype: "Second"
self.browser.find_link_by_href(
'/schemas/bobs-graph/types/create/').first.click()
self.browser.find_by_name('name').first.fill("Second")
self.browser.find_by_name('properties-0-key').first.fill('Name')
self.browser.find_by_name('properties-0-display').first.check()
self.browser.find_by_value('Save Type').first.click()
self.browser.find_by_id('dataMenu').first.click()
# Creating an allowed relationship: "First -> First"
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill('FirstToFirst')
self.browser.select('target', '1')
self.browser.find_by_value('Save Type').first.click()
# Creating an allowed relationship: "First -> Second"
self.browser.find_by_id('allowedRelations').first.click()
self.browser.select('source', '1')
self.browser.find_by_name('name').fill('FirstToSecond')
self.browser.select('target', '2')
self.browser.find_by_value('Save Type').first.click()
# Creating a node of the "First" type
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
self.browser.find_by_name('Name').first.fill("First1")
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
real_nodes += 1
# Creating another node of the "First" type
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
self.browser.find_by_name('Name').first.fill("First2")
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
real_nodes += 1
# Creating a node of the "Second" type
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
self.browser.find_by_name('Name').first.fill("Second1")
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
real_nodes += 1
# Creating another node of the "Second" type
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
self.browser.find_by_name('Name').first.fill("Second2")
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
real_nodes += 1
# Creating another node of the "Second" type
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
self.browser.find_by_name('Name').first.fill("Second3")
self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
real_nodes += 1
# Editing the "First1" node
self.browser.find_by_id('dataMenu').first.click()
self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
# Adding more "FirstToSecond" relationship forms
self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
# Adding the relationships
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First2')
self.browser.is_element_present_by_id("id_user_wait", 3)
self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
real_rels += 1
self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
#.........这里部分代码省略.........
示例14: TestViews
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import find_link_by_href [as 别名]
class TestViews(unittest.TestCase):
def setUp(self):
""" Test setup """
self.browser = Browser("phantomjs")
# Set up the tables in the database
Base.metadata.create_all(engine)
# Create an example user
self.user = models.User(name="Alice", email="[email protected]",
password=generate_password_hash("test"))
session.add(self.user)
session.commit()
port = int(os.environ.get('PORT', 8080))
self.process = multiprocessing.Process(target=app.run, kwargs = {'host':'0.0.0.0','port':8080})
self.process.start()
time.sleep(1)
def tearDown(self):
""" Test teardown """
# Remove the tables and their data from the database
self.process.terminate()
Base.metadata.drop_all(engine)
self.browser.quit()
def login(self):
""" Log into the site """
self.browser.visit("http://0.0.0.0:8080/login")
self.browser.fill("email", "[email protected]")
self.browser.fill("password", "test")
button = self.browser.find_by_css("button[type=submit]")
button.click()
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")
def testAddPost(self):
self.login()
print 'We are logged in:'
self.browser.visit("http://0.0.0.0:8080/post/add")
self.browser.fill("title", "This is an example post")
self.browser.fill("content", "test")
button = self.browser.find_by_css("button[type=submit]")
button.click()
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")
self.assertEqual(self.browser.is_text_present('This is an example post'),True)
def testDeletePost(self):
self.login()
self.testAddPost()
self.browser.visit("http://0.0.0.0:8080/post/1/delete")
self.browser.visit("http://0.0.0.0:8080/")
self.assertEqual(self.browser.is_text_present('This is an example post'),False)
def testUpdatePost(self):
self.login()
self.testAddPost()
self.browser.visit("http://0.0.0.0:8080/post/1/edit")
self.browser.fill("title", "This is an example post UPDATED TITLE")
self.browser.fill("content", "test NEW CONTENT")
button = self.browser.find_by_css("button[type=submit]")
button.click()
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")
self.assertEqual(self.browser.is_text_present('UPDATED TITLE'),True)
self.assertEqual(self.browser.is_text_present('NEW CONTENT'),True)
def testLoginCorrect(self):
self.browser.visit("http://0.0.0.0:8080/login")
self.browser.fill("email", "[email protected]")
self.browser.fill("password", "test")
button = self.browser.find_by_css("button[type=submit]")
button.click()
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")
def testLogout(self):
self.testLoginCorrect()
self.browser.visit("http://0.0.0.0:8080/logout")
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/")
self.assertTrue(self.browser.find_link_by_href('/login'))
def testLoginIncorrect(self):
self.browser.visit("http://0.0.0.0:8080/login")
self.browser.fill("email", "[email protected]")
self.browser.fill("password", "test")
button = self.browser.find_by_css("button[type=submit]")
button.click()
self.assertEqual(self.browser.status_code.is_success(),True)
self.assertEqual(self.browser.url, "http://0.0.0.0:8080/login")