Added new selenium locator examples.
Fixed find_elements in WEB_DRIVER.
This commit is contained in:
@@ -30,4 +30,28 @@
|
||||
<root class="FIND_ELEMENT_CLASS" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementChild" extends="selenium_example">
|
||||
<root class="FIND_ELEMENT_CHILD" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementsLinks" extends="selenium_example">
|
||||
<root class="FIND_ELEMENTS_LINKS" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementsLinksByText" extends="selenium_example">
|
||||
<root class="FIND_ELEMENTS_LINKS_BY_TEXT" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementsLinksByPartialText" extends="selenium_example">
|
||||
<root class="FIND_ELEMENTS_LINKS_BY_PARTIAL_TEXT" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="findElementCssSelector" extends="selenium_example">
|
||||
<root class="FIND_ELEMENT_CSS_SELECTOR" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
|
||||
</system>
|
||||
|
||||
61
library/test/selenium/examples/find_element_child.e
Normal file
61
library/test/selenium/examples/find_element_child.e
Normal file
@@ -0,0 +1,61 @@
|
||||
note
|
||||
description: "The WEB_ELEMENT class also supports find methods that find child elements."
|
||||
|
||||
class
|
||||
FIND_ELEMENT_CHILD
|
||||
|
||||
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
|
||||
wait: WEB_DRIVER_WAIT
|
||||
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 login page
|
||||
web_driver.to_url ("http://www.eiffelroom.com/")
|
||||
|
||||
-- Find the element div with id page,and then we can find a child element div page-inner
|
||||
--<div id="page">
|
||||
-- <div id="page-inner">
|
||||
-- <a id="navigation-top" name="top"></a>
|
||||
-- <div id="skip-to-nav">
|
||||
-- <div id="header">
|
||||
-- <div id="main">
|
||||
-- <div id="footer">
|
||||
-- </div>
|
||||
--</div>
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("page")) as l_div_page then
|
||||
print ("%N Page element id" + l_div_page.element)
|
||||
if attached {WEB_ELEMENT}l_div_page.find_element ((create {SE_BY}).id ("page-inner")) as l_div_page_inner then
|
||||
print ("%N Inner Page element id" + l_div_page_inner.element)
|
||||
end
|
||||
end
|
||||
-- close the window
|
||||
web_driver.window_close
|
||||
print ("%N")
|
||||
end
|
||||
|
||||
end
|
||||
66
library/test/selenium/examples/find_element_css_selector.e
Normal file
66
library/test/selenium/examples/find_element_css_selector.e
Normal file
@@ -0,0 +1,66 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
FIND_ELEMENT_CSS_SELECTOR
|
||||
|
||||
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
|
||||
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/")
|
||||
|
||||
-- Absolute Path
|
||||
-- <div id="header">
|
||||
-- html.js body.front div#page div#page-inner div#header
|
||||
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).css_selector ("html.js body.front div#page div#page-inner div#header")) as selector then
|
||||
print ("%NElement:" + selector.element)
|
||||
end
|
||||
|
||||
-- Relative Path
|
||||
--
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).css_selector ("div#header")) as selector then
|
||||
print ("%NElement:" + selector.element)
|
||||
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
|
||||
65
library/test/selenium/examples/find_elements_links.e
Normal file
65
library/test/selenium/examples/find_elements_links.e
Normal file
@@ -0,0 +1,65 @@
|
||||
note
|
||||
description: "[
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
FIND_ELEMENTS_LINKS
|
||||
|
||||
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
|
||||
wait: WEB_DRIVER_WAIT
|
||||
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/")
|
||||
|
||||
create wait.make (web_driver,10)
|
||||
wait.until_when (agent expected_title (web_driver, "Eiffel Room"))
|
||||
|
||||
|
||||
-- Find links
|
||||
if attached {ARRAYED_LIST[WEB_ELEMENT]}web_driver.find_elements ((create {SE_BY}).tag_name("a")) as l_links then
|
||||
from
|
||||
l_links.start
|
||||
until
|
||||
l_links.after
|
||||
loop
|
||||
if attached l_links.item.get_attribute ("href") as l_ref then
|
||||
print ("%Nhref:" + l_ref)
|
||||
end
|
||||
l_links.forth
|
||||
end
|
||||
end
|
||||
print ("%Nend process ..." )
|
||||
io.read_line
|
||||
-- close the window
|
||||
web_driver.window_close
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,71 @@
|
||||
note
|
||||
description: "[
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
FIND_ELEMENTS_LINKS_BY_PARTIAL_TEXT
|
||||
|
||||
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
|
||||
wait: WEB_DRIVER_WAIT
|
||||
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/")
|
||||
|
||||
-- Find links
|
||||
-- <a href="http://www.eiffel.com">Eiffel.com</a></li><li><a>
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).partial_link_text("Eiffel")) as l_link then
|
||||
if attached l_link.get_attribute ("href") as l_ref then
|
||||
print ("%Nhref:" + l_ref)
|
||||
end
|
||||
end
|
||||
-- <a href="#navigation">Skip to Navigation</a>
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).partial_link_text("Skip to")) as l_link then
|
||||
if attached l_link.get_attribute ("href") as l_ref then
|
||||
print ("%Nhref:" + l_ref)
|
||||
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
|
||||
55
library/test/selenium/examples/find_elements_links_by_text.e
Normal file
55
library/test/selenium/examples/find_elements_links_by_text.e
Normal file
@@ -0,0 +1,55 @@
|
||||
note
|
||||
description: "[
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
FIND_ELEMENTS_LINKS_BY_TEXT
|
||||
|
||||
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
|
||||
wait: WEB_DRIVER_WAIT
|
||||
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/")
|
||||
|
||||
-- Find links
|
||||
-- <a href="http://www.eiffel.com">Eiffel.com</a></li><li><a>
|
||||
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).link_text("Eiffel.com")) as l_link then
|
||||
if attached l_link.get_attribute ("href") as l_ref then
|
||||
print ("%Nhref:" + l_ref)
|
||||
end
|
||||
end
|
||||
print ("%Nend process ..." )
|
||||
io.read_line
|
||||
-- close the window
|
||||
web_driver.window_close
|
||||
end
|
||||
|
||||
end
|
||||
6
library/test/selenium/examples/project.rc
Normal file
6
library/test/selenium/examples/project.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
1 "This Program was made using EiffelStudio using Visual Studio C++"
|
||||
END
|
||||
6
library/test/selenium/examples/selenium_example.rc
Normal file
6
library/test/selenium/examples/selenium_example.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
1 "This Program was made using EiffelStudio using Visual Studio C++"
|
||||
END
|
||||
Reference in New Issue
Block a user