Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
wendelin
Commits
8ff32465
Commit
8ff32465
authored
Mar 31, 2023
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drop old utils
parent
5ba6dae6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
544 deletions
+0
-544
utils/LOOP-ON-COMBINATIONS-selenium-script.py
utils/LOOP-ON-COMBINATIONS-selenium-script.py
+0
-313
utils/[OBSOLETE]drone-app-backup.py
utils/[OBSOLETE]drone-app-backup.py
+0
-93
utils/selenium-on-headless-chrome-notes
utils/selenium-on-headless-chrome-notes
+0
-138
No files found.
utils/LOOP-ON-COMBINATIONS-selenium-script.py
deleted
100644 → 0
View file @
5ba6dae6
This diff is collapsed.
Click to expand it.
utils/[OBSOLETE]drone-app-backup.py
deleted
100644 → 0
View file @
5ba6dae6
NUMBER_OF_DRONES
=
1
INPUT_ID_LIST
=
[
"simulation_speed"
,
"simulation_time"
,
"drone_speed"
,
"number_of_drones"
]
INPUT_VALUE_LIST
=
[
300
,
1000
,
16
,
NUMBER_OF_DRONES
]
AI_SCRIPT
=
'me.onStart = function () {console.log("start");};me.onUpdate = function (timestamp) {console.log("update!");};'
import
certifi
import
urllib3
import
time
from
selenium
import
webdriver
from
selenium.webdriver.chrome.options
import
Options
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.common.desired_capabilities
import
DesiredCapabilities
from
selenium.webdriver.remote.remote_connection
import
RemoteConnection
# configure the web driver settings
options
=
Options
()
options
.
add_argument
(
'headless'
)
options
.
add_argument
(
'--headless=new'
)
options
.
add_argument
(
'incognito'
)
options
.
add_argument
(
'--no-sandbox'
)
options
.
add_argument
(
'window-size=1200x2600'
)
dc
=
DesiredCapabilities
.
CHROME
dc
[
'loggingPrefs'
]
=
{
'browser'
:
'ALL'
}
# local selenium
#driver = webdriver.Chrome(options=options, desired_capabilities=dc)
# run selenium remote server
server_url
=
"https://selenium:jvT0SRR9Mtad@softinst179949.host.vifib.net/wd/hub"
executor
=
RemoteConnection
(
server_url
,
keep_alive
=
True
)
cert_reqs
=
'CERT_REQUIRED'
ca_certs
=
certifi
.
where
()
executor
.
_conn
=
urllib3
.
PoolManager
(
cert_reqs
=
cert_reqs
,
ca_certs
=
ca_certs
)
driver
=
webdriver
.
Remote
(
command_executor
=
executor
,
desired_capabilities
=
dc
,
)
# navigate to drone app
url
=
"https://dronesimulator.app.officejs.com/"
#url = "https://softinst157899.host.vifib.net/erp5/web_site_module/officejs_drone_simulator/"
driver
.
get
(
url
)
driver
.
implicitly_wait
(
5
)
# skip bootloader
skip
=
driver
.
find_element
(
By
.
XPATH
,
'//a[@class="skip-link" and text()="Skip"]'
)
skip
.
click
()
# wait for editor iframe content
driver
.
implicitly_wait
(
10
)
iframe
=
driver
.
find_element
(
By
.
XPATH
,
'//iframe'
)
# fill all standard inputs
for
i
,
input_id
in
enumerate
(
INPUT_ID_LIST
):
input
=
driver
.
find_element
(
By
.
ID
,
input_id
)
input
.
clear
()
input
.
send_keys
(
INPUT_VALUE_LIST
[
i
])
# fill codemirror editor input
frame
=
driver
.
find_element
(
By
.
XPATH
,
'//iframe'
)
driver
.
switch_to
.
frame
(
frame
)
#driver.execute_script('return document.getElementsByClassName("CodeMirror")[0].CodeMirror.setValue("' + AI_SCRIPT + '")')
driver
.
switch_to
.
default_content
()
#run the simulation
run_button
=
driver
.
find_element
(
By
.
XPATH
,
'//input[@type="submit" and @name="action_run"]'
)
run_button
.
click
()
driver
.
implicitly_wait
(
30
)
loading
=
driver
.
find_element
(
By
.
XPATH
,
'//span[@id="loading"]'
)
time
.
sleep
(
20
)
#screenshot
driver
.
get_screenshot_as_file
(
'main-page.png'
)
# download all result logs
for
i
in
range
(
NUMBER_OF_DRONES
):
text
=
"Download Simulation LOG "
+
str
(
i
)
id_s
=
"log_result_"
+
str
(
i
)
download_log
=
driver
.
find_element
(
By
.
XPATH
,
'//div[@class="container"]//a[contains(text(), "'
+
text
+
'")]'
)
#download_log.click() #saves log txt file in command location
result_log
=
driver
.
find_element
(
By
.
XPATH
,
'//div[@class="container"]//textarea[@id="'
+
id_s
+
'"]'
)
result_list
[
i
]
=
result_log
.
get_attribute
(
'value'
)
# at this point, we have all the drone logs generated as txt files in command execution directory
#screenshot
driver
.
get_screenshot_as_file
(
'main-page.png'
)
#print browser log entries
for
entry
in
driver
.
get_log
(
'browser'
):
print
(
entry
)
driver
.
quit
()
\ No newline at end of file
utils/selenium-on-headless-chrome-notes
deleted
100644 → 0
View file @
5ba6dae6
--------------------------------------------------------------------------------------------------------------------------
---------------------------------- INSTALLATION NOTES
--------------------------------------------------------------------------------------------------------------------------
install pip3
apt install python3-pip
install virtualenv
pip3 install virtualenv
#
create and activate a virtualenv
virtualenv env
.
env/bin/activate
install selenium
pip3 install selenium
install ipython
pip3 install ipython
install bsdtar
apt install ipython
#install
chromedriver
PLATFORM=linux64
VERSION=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
curl http://chromedriver.storage.googleapis.com/$VERSION/chromedriver_$PLATFORM.zip \
|
bsdtar -xvf - -C env/bin/
#If doesn't work (chromedriver not found), install it manually
wget https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
#move binary to env bin dir
sudo mv chromedriver to roquenv/bin/
run chromedriver (with path probably)
Starting ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
#Be sure to have an up to date chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
--------------------------------------------------------------------------------------------------------------------------
---------------------------------- SELEMIUM USE NOTES AND USE
--------------------------------------------------------------------------------------------------------------------------
#then in interactive python (ipython)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(options=options)
url = "https://dronesimulator.app.officejs.com/"
driver.get(url)
print(driver.page_source.encode("utf-8"))
# wait up to 10 seconds for the elements to become available
driver.implicitly_wait(10)
email = driver.find_element_by_css_selector('input[type=email]')
email.send_keys('evan@intoli.com')
driver.get_screenshot_as_file('main-page.png')
login.click()
user_input = driver.find_element_by_id("username")
user_input.send_keys(username)
speed_input = driver.find_element(By.ID, "simulation_speed")
ID = "id"
NAME = "name"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
TAG_NAME = "tag name"
CLASS_NAME = "class name"
CSS_SELECTOR = "css selector"
speed_input.clear()
speed_input.send_keys(SPEED)
driver.find_element(By.XPATH, '//button[text()="Some text"]')
driver.find_element(By.XPATH, '//div[@class="CodeMirror-code"]')
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment