So, I have a web application at work that needs to collect information and create some reports and do some basic data analysis.
The thing is, I'm a complete newbie to HTML, Ajax (asynchronous JavaScript and XML), Python, and Selenium.
What I collect so far is the following:
- Ajax nature is to perform asynchronous actions in a web browser and, in my case, send server requests for push / pull some data li>
- Selenium handles asynchronous events that perform actions
Wait
, such as:- time.sleep ('time in ms') # using the time library. So it is NOT REALLY Selenium;
- Explicit expectations: you define to wait for a certain condition to appear before continuing with the code;
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
delay_time = 10
driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
webDriverWait(driver,delay_time)\
.until(EC.presence_of_element_located((By.ID, 'IdOfMyElement')))`
EC means the expected conditions represented by:
title_is
title_contains;
presence_of_element_located
visibility_of_element_located
visibility_of
presence_of_all_elements_located
text_to_be_present_in_element
text_to_be_present_in_element_value
frame_to_be_available_and_switch_to_it
invisibility_of_element_located
element_to_be_clickable
staleness_of
element_to_be_selected
element_located_to_be_selected
element_selection_state_to_be
element_located_selection_state_to_be
alert_is_present
- Implicit expectations: ask WebDriver to poll the DOM (Document Object Model) for a certain period of time when trying to find an element or elements if they are not immediately available;
driver.implicitly_wait(10)
- - JavaScript Java wait: j Query Ajax query.active.
- FluentWait: FluentWait ;
- WebdriverWait: ExpectedCondition WebDriverWait.
, :
Ajax.
<div id="div_39_1_3" class="Button CoachView CPP BPMHSectionChild CoachView_show" data-type="com.ibm.bpm.coach.Snapshot_b24acf10_7ca3_40fa_b73f_782cddfd48e6.Button" data-binding="local.clearButton" data-bindingtype="boolean" data-config="config175" data-viewid="GhostClear" data-eventid="boundaryEvent_42" data-ibmbpm-layoutpreview="horizontal" control-name="/GhostClear">
<button class="btn btn-labeled"><span class="btn-label icon fa fa-times"></span>Clear</button></div>
: function(a) {!e._instance.btn.disabled &&
c.ui.executeEventHandlingFunction(e, e._proto.EVT_ONCLICK) &&
(e._instance.multiClicks || (e._instance.btn.disabled = !0,
f.add(e._instance.btn, "disabled")), e.context.binding &&
e.context.binding.set("value", !0), e.context.trigger(function(a) {
e._instance.btn.disabled = !1;
f.remove(e._instance.btn, "disabled");
setTimeout(function() {
c.ui.executeEventHandlingFunction(e, e._proto.EVT_ONBOUNDARYEVT,
a.status)
})
}, {
callBackForAll: !0
}))
}
, ajaxCoach

/, AJAX
Python?