Handling with random button with Robot Framework
I'm trying to use Robot Framework with SeleniumLibrary to click on a random button generator, the HTML was:
<div class="btn-number-password noselect">
<p class="btn btn-secondary btn-userpassword" data-keyboard="0">6 or 7</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="1">2 or 0</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="2">3 or 8</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="3">9 or 4</p>
<p class="btn btn-secondary btn-userpassword" data-keyboard="4">5 or 1</p></div>
It will generete buttons to a field like:
[6 or 7] [2 or 0] [3 or 8] [9 or 4] [5 or 1]
These numbers shuffle everytime, so I'm trying to click using text but nothing what I tried works.
Is there any way to click with Robot using text in these buttons?
See also questions close to this topic
-
Adopting code from Oddsportal URL to current & Next Page
I have a code that scrapes
https://www.oddsportal.com/soccer/england/premier-league/
odds and event data.
I want to adopt the same to get all data for "today" which is reflected at
https://www.oddsportal.com/matches/soccer/
and 'tomorrow' is
https://www.oddsportal.com/matches/soccer/20210309/
which is essentially
url/today+1
My current code that works is:
browser = webdriver.Chrome() browser.get("https://www.oddsportal.com/soccer/england/premier-league/") df = pd.read_html(browser.page_source, header=0)[0] dateList = [] gameList = [] home_odds = [] draw_odds = [] away_odds = [] for row in df.itertuples(): if not isinstance(row[1], str): continue elif ':' not in row[1]: date = row[1].split('-')[0] continue time = row[1] dateList.append(date) gameList.append(row[2]) home_odds.append(row[4]) draw_odds.append(row[5]) away_odds.append(row[6]) result = pd.DataFrame({'date': dateList, 'game': gameList, 'Home': home_odds, 'Draw': draw_odds, 'Away': away_odds})
Because the
datelist[]
is different to the links e.g.Algeria»Ligue 1
I am getting an errorNameError: name 'date' is not defined
How can I adopt the same to
https://www.oddsportal.com/matches/soccer/
and for
tomorrow
? -
How do I download an jsp file into a pdf with selenium?
I need to download the jsp inside of an iframe using selenium. It has to be in a pdf format.
How do I manage to do this?
<iframe id="miBody" name="miBody" src="/padron-puc-constancia-internet/jsp/Constancia.jsp" height="150%" width="100%" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" align="top" style="height: 629px;"></iframe>
-
Headless Chrome driver unable to fetch Instagram page in python Selenium driver
I tried to login and scrape a few details from my Instagram page in Python. I wanna do it in the headless mode because I'm going to deploy it in Heroku. So when I try to login using this code in the headless Chrome driver, the Instagram login page is not fetched. I have provided the screenshot also.
def login_insta(driver,username,password): driver.get("https://www.instagram.com/accounts/login") time.sleep(5) driver.save_screenshot('scrnsh.png') driver.find_element_by_xpath( "//input[@name='username']").send_keys(username) driver.find_element_by_xpath( "//input[@name='password']").send_keys(password) driver.find_element_by_xpath("//button/div[text()='Log In']").click() print("Logged in") options = Options() PATH = r"C:\Users\pcname\Downloads\chromedriver" options.add_argument("--headless") options.add_argument("--disable-dev-shm-usage") options.add_argument("--no-sandbox") options.add_argument('--disable-gpu') driver = webdriver.Chrome(executable_path=PATH, chrome_options=options) login_insta(driver,"name","pass")
The screenshot said "Error Please wait a few minutes before you try again" This error doesn't occur with the headlesss Firefox driver, I don't how to add Firefox buildpacks in Heroku. I have recent Chrome driver version. Please help me solve this issue.
Or if you can suggest buildpacks for Firefox for Heroku, and the steps to add them, it would be very helpful. Thank you!
-
Skipping popup with robot framework does not skip it
I have to skip a popup which appears only for some users, it may take 10-20 seconds for this popup to be visible on the screen and I created keyword which is inside Login to Page keyword which is in Suite Setup. For some reason it does not see the popup and it fails Test Cases because popup is not closed, the 1st part of the keyword returns True. Could you please try to help me to understand why or advice a better way to implement the Close Walkthrough... keywords?
Skip Guide If It is Opened ${ELEMS}= Run Keyword and Return Status ... Execute Javascript localStorage.getItem('applicationTourDismiss') Run Keyword If '${ELEMS}'== 'False' Click Button ${SKIP_BUTTON}
-
Error when trying to interact with an SAP element using the SapGuiLibrary from Robot Framework
I am using SapGuiLibrary to automate some tests in SAP GUI screens using the Robot Framework. To identify the elements I am using the Script Tracker and I was able to identify the element I want to interact with, but when I click on it, or change the value of the field I get the error message:
ValueError: Cannot find element with id 'wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0]'
Here is what I'm doing:
*** Settings *** Library SapGuiLibrary Resource ../Resource/Login_PartLinQ.robot *** Variables *** ${Btn_DeleteRow} wnd[1]/tbar[0]/btn[14] ${SAP_Title} /app/con[0]/ses[0]/wnd[0]/titl ${Tab_DocsXVendor} wnd[0]/usr/cntlMEALV_GRID_CONTROL_VL31/shellcont/shell ${Txt_DeliveryQtd} wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0] ${Txt_DocCategory} wnd[0]/usr/ctxtSP$00004-LOW ${Txt_Material} wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/ctxtLIPS-MATNR[1,0] ${Txt_MaterNumber} wnd[0]/usr/ctxtS_MATNR-LOW ${Txt_Plant} wnd[0]/usr/ctxtSP$00023-LOW ${Txt_PurchasDoc} wnd[0]/usr/ctxtSP$00005-LOW ${Txt_PurchasGroup} wnd[0]/usr/ctxtSP$00006-LOW ${Txt_SelecParam} wnd[0]/usr/ctxtSP$00010-LOW *** Keywords *** ### Given ### that the user is logged into PartLinQ ${title} Get Value ${SAP_Title} Should Be Equal ${title} SAP Easy Access ${SPACE}-${SPACE} User Menu for test ID for automated Test Scripts 1 ### When ### the user update the Business Partner Run Transaction VL31N Send Vkey Shift + F4 Input Text ${Txt_MaterNumber} VO 82713508 Input Text ${Txt_PurchasDoc} 1000005844 Set Focus ${Txt_PurchasGroup} Send Vkey F2 Click Element ${Btn_DeleteRow} Set Focus ${Txt_DocCategory} Send Vkey F2 Click Element ${Btn_DeleteRow} Set Focus ${Txt_SelecParam} Send Vkey F2 Click Element ${Btn_DeleteRow} Set Focus ${Txt_Plant} Send Vkey F2 Click Element ${Btn_DeleteRow} Send Vkey F8 Select Table Row ${Tab_DocsXVendor} 0 Send Vkey F8 Input Text ${Txt_DeliveryQtd} 5
That's what I got from Script Tracker:
$ID = Invoke-Method -object $session -methodName "findById" -methodParameter @("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0]");
Set-Property -object $ID -propertyName "text" -propertyValue @("5"); -
Error while incrementing the value in Robot Framework
*** Settings *** Library DateTime *** Test Cases *** Test title ${TIME}= get current date result_format=%H RUN KEYWORD IF ... int(${TIME})%2==0 ... ${TIME}= catenate SEPARATOR= ${TIME} :00 ... ELSE ... ${TIME}= Evaluate int(${TIME})+1 ... ${TIME}= catenate SEPARATOR= ${TIME} :00 log to console ${TIME}
I'm getting the following error:
No keyword with name '11=' found.