It works when "headless = False",but It does not work when "headless = True"
sshuangliu opened this issue · comments
hi ,all
help...
python code as follow:
`
from helium import *
from selenium.webdriver import ChromeOptions
import time
from datetime import datetime
options = ChromeOptions()
options.add_argument('--proxy-server=127.0.0.1:10809')
username = 'xxxx'
url = 'https://xxxx/xxLogin'
start_chrome(url=url, headless=False, options=options)
wait_until(Button("Proceed").exists)
write(username, into=S("#form1")) # write base on the HTML element id value
time.sleep(1)
click(Button("Proceed")) #can also use with press(ENTER)
a = input('please input a one-time token:')
write(a, into=S("#authcode1"))
click(Button("Login"))
time.sleep(4)
sub_url = 'https://xxxx/timesheet'
go_to(sub_url)
#scroll_down(num_pixels=600)
wait_until(Image("Cancle-Icon").exists)
print('has found the cancle-icon')
#this is used to close Popup
if Image("Cancle-Icon").exists():
click(Image("Cancle-Icon"))
print("cannle popup")
time.sleep(1)
write("8", into=S("#effortforOwnWonSwon11"))
#write("18", into=S('//*[@id="effortforOwnWonSwon11"]'))
#write("8", into=S('.textBoxClass ng-pristine ng-valid showClass'))
time.sleep(1)
click(Button("Submit"))`
HTML code as follow:
`
<div style="margin-top: 10px; white-space: nowrap;">
<div id="effortDivforOwnWonSwon11" ng-class="setVisibility(ctEffortBean,$parent.$index,$index,'O','effortDivforOwnWonSwon'+$parent.$index+$index);" style="padding-right: 10px; float: left;text-align:center; width: 65px;" class="showClass">
<input id="effortforOwnWonSwon11" maxlength="5" type="text" ng-init="oldValue=' '" ng-focus="oldValue = ctEffortBean.hoursWorked" ng-blur="changeHours($parent.$index,$index,oldValue,'O','fromBody',activity.projWon);" ng-model="ctEffortBean.hoursWorked" ng-class="setVisibility(ctEffortBean,$parent.$index,$index,'O','effortforOwnWonSwon'+$parent.$index+$index);" ng-disabled="isEffortEnabled(activity.effortDisabled);" ng-keypress="isTwoDecimalPlaces(ctEffortBean.hoursWorked,$event)" class="textBoxClass ng-pristine ng-valid showClass">
</div>
</div>
</td>`
The "write("8", into=S("#effortforOwnWonSwon11"))" work, but it does not work when "start_chrome(url=url, headless=True, options=options)" and raise an error ‘raise LookupError()’
I am so upset for that, I have tried three methods to identifying HTML elements by id,class and xpath, but it all does not work when headless is set with “True”.
now I have no idea what I should do next
thanks in advance
10/12/2021