Updated command_executor
Added more examples.
This commit is contained in:
@@ -50,6 +50,12 @@
|
||||
<root class="FIND_ELEMENT_CSS_SELECTOR" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementXPath" extends="selenium_example">
|
||||
<root class="FIND_ELEMENT_XPATH" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ feature -- Search by id
|
||||
if attached web_driver.get_page_tile as l_title then
|
||||
print ("%NPage title is:" + l_title)
|
||||
end
|
||||
|
||||
-- Find the user name, password element by its id and submit
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-name")) as l_user and then attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-pass")) as l_pass and then attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-submit")) as l_form then
|
||||
if attached l_user.get_css_value ("width") as l_width then
|
||||
print ("%NCss value:" + l_width)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
io.read_line
|
||||
-- close the window
|
||||
web_driver.window_close
|
||||
end
|
||||
|
||||
74
library/test/selenium/examples/find_element_xpath.e
Normal file
74
library/test/selenium/examples/find_element_xpath.e
Normal file
@@ -0,0 +1,74 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
FIND_ELEMENT_XPATH
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature
|
||||
|
||||
default_create
|
||||
do
|
||||
search
|
||||
end
|
||||
|
||||
feature -- Search by id
|
||||
|
||||
search
|
||||
local
|
||||
web_driver: WEB_DRIVER
|
||||
xpath_expression : STRING_32
|
||||
do
|
||||
--Create a new instance of a Web driver
|
||||
create web_driver.make
|
||||
|
||||
-- Start session with chrome
|
||||
web_driver.start_session_chrome
|
||||
|
||||
-- Go to EiffelRoom home page
|
||||
web_driver.to_url ("http://www.eiffelroom.com/")
|
||||
|
||||
|
||||
--Xpath expression
|
||||
xpath_expression := "//*[@id='page']"
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).xpath (xpath_expression)) as l_path then
|
||||
print ("%NElement:" + l_path.element)
|
||||
end
|
||||
|
||||
-- Images with Alt
|
||||
-- img[@alt]
|
||||
if attached {LIST[WEB_ELEMENT]}web_driver.find_elements ((create {SE_BY}).xpath ("//img[@alt]")) as l_paths then
|
||||
from
|
||||
l_paths.start
|
||||
until
|
||||
l_paths.after
|
||||
loop
|
||||
print ("%NElement:" + l_paths.item.element)
|
||||
l_paths.forth
|
||||
end
|
||||
end
|
||||
|
||||
print ("%Nend process ...")
|
||||
io.read_line
|
||||
-- close the window
|
||||
web_driver.window_close
|
||||
end
|
||||
|
||||
expected_title (driver: WEB_DRIVER; title: STRING_32): BOOLEAN
|
||||
do
|
||||
if attached {STRING_32} driver.get_page_tile as l_title and then l_title.has_substring (title) then
|
||||
Result := True
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user