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
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.webdriver.common.action_chains
import
ActionChains
from
selenium.webdriver.common.keys
import
Keys
def
init_driver():
driver
=
webdriver.Firefox(executable_path
=
"C:\\Users\\jpedr\\Desktop\\geckodriver-v0.26.0-win64\\geckodriver.exe"
)
driver.implicitly_wait(
5
)
driver.wait
=
WebDriverWait(driver,
15
)
return
driver
def
my_function(i,driver):
while
i<b:
import
time
time.sleep(
15
)
driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
element
=
driver.wait.until(EC.presence_of_element_located((By.XPATH,f[i])))
while
True
:
try
:
if
find_element_by_xpath(f[i])
is
True
:
element1
=
driver.find_element_by_xpath(f[i])
driver.find_element_by_xpath(f[i]).click()
except
ValueError:
print
(
"no more"
)
pass
try
:
element
=
driver.find_element_by_xpath(f[i])
driver.execute_script(
"arguments[0].click();"
, element)
except
NoSuchElementException as e:
print
(
"no"
)
try
:
myDynamicElement
=
driver.find_element_by_xpath(
"/html/body/div[2]/div/form/input"
)
driver.find_element_by_xpath(
"/html/body/div[2]/main/input"
).click()
except
NoSuchElementException as e:
driver.wait.until(EC.presence_of_element_located((By.XPATH,
"/html/body/div/form/input"
)))
import
time
time.sleep(
2
)
driver.back()
i
=
i
+
1
a
=
0
i
=
0
b
=
0
bypass
=
0
driver
=
init_driver()
f1
=
"/html/body/section[1]"
f2
=
"/html/body/section[2]"
f
=
[f1,f2]
driver.wait.until(EC.presence_of_element_located((By.XPATH,
"/html/body/section[1]"
)))
driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
try
:
c1
=
driver.find_element_by_xpath(
"/html/body/section[1]"
)
a
=
a
+
1
except
NoSuchElementException as e:
print
(
"no"
)
import
time
time.sleep(
10
)
if
a>
0
:
driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
driver.find_element_by_xpath(
"/html/body/div[3]"
).click()
element
=
driver.wait.until(EC.presence_of_element_located((By.XPATH,
"/html/body/section[1]"
)))
driver.find_element_by_xpath(
"/html/body"
).click()
try
:
myDynamicElement
=
driver.find_element_by_xpath(
"/html/body/div[2]"
)
driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
import
time
time.sleep(
2
)
driver.find_element_by_xpath(
"/html/body"
).click()
try
:
myDynamicElement
=
driver.find_element_by_xpath("
/
html
/
body
/
div[
2
]
driver.find_element_by_xpath(
"/html/body/div[2]"
).click()
driver.wait.until(EC.presence_of_element_located((By.NAME,
"username"
)))
driver.find_element_by_name(
"username"
)
import
time
time.sleep(
2
)
driver.find_element_by_name(
"username"
).send_keys("")
driver.wait.until(EC.presence_of_element_located((By.NAME,
"password"
)))
driver.find_element_by_name(
"password"
)
import
time
time.sleep(
2
)
driver.find_element_by_name(
"password"
).send_keys("")
import
time
time.sleep(
2
)
driver.wait.until(EC.presence_of_element_located((By.XPATH,
"/html/body/div[2]"
)))
driver.find_element_by_xpath(
"/html/body"
)
driver.find_element_by_xpath(
"/html/body"
).click()
import
time
time.sleep(
2
)
try
:
driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
d1
=
driver.find_element_by_xpath(
"/html/body/div[2]/main/"
)
b
=
b
+
1
d2
=
driver.find_element_by_xpath(
"/html/body/div[2]"
)
b
=
b
+
1
except
NoSuchElementException as e:
print
(
"no more"
)
if
b>
0
:
my_function(
0
,driver)