"Choose File" in "seleniumlibrary" in robotframework - selenium

I'm trying to browse multiple files (one after the other ) using the keyword "Choose File" for the attached screen.
The circled in red are the web elements through which files are to be browsed ( top right ).
The page code is highlighted in red.
The xpath circled in black ( bottom left ) , which when searched, highlights both the web elements one after another which browse the file.
Below are my steps:
Scroll Element Into View xpath=//span[contains(#class,'filebrowse .click')]
Wait Until Element is visible xpath=//span[contains(#class,'filebrowse .click')]
Set Focus To Element xpath=//span[contains(#class,'filebrowse .click')]
Choose File xpath=//span[contains(#class,'filebrowse .click')] ${file_path}
I got the error below for the step above - "Choose File" :
WebDriverException: Message: unknown error: cannot focus element
(Session info: chrome=71.0.3578.98)
(Driver info: chromedriver=2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.10586 x86_64)

I used the below code and worked fine.
Libraries Used :
Library pyautogui
Library ImageHorizonLibrary
Code sample :
Scroll Element Into View xpath=//div[1]/div[5]/a/span
Wait Until Element is visible xpath=//div[1]/div[5]/a/span
Set Focus To Element xpath=//div[1]/div[5]/a/span
Click Element xpath=//div[1]/div[5]/a/span
Sleep 5s
pyautogui.Typewrite file_name.jpg
pyautogui.Key Down 'enter'
ImageHorizonLibrary.Press Combination Key.enter
Sleep 15s
For this I had to keep the file "file_name.jpg" in a default browse folder.
Identified the default folder through a sample code run.

Related

Error in Click Element At Coordinates keyword using Robot Framework

I am debugging a provided script in robot framework with the below peace of lines:-
*** Variables ***
${administration} <sample xpath>
*** Keywords ***
Click Next Network
Click Element At Coordinates ${administration} 10 460
Sleep 3
Click Done Network
Click Element At Coordinates ${administration} 70 460
Sleep 3
Click Close Network
Click Element At Coordinates ${administration} -40 460
Sleep 3
While Executing the script is not working as per the coordinates provided and throwing error:-
MoveTargetOutOfBoundsException: Message: move target out of bounds
(Session info: chrome=105.0.5195.127)
Please provide some guidelines on how can we get the correct coordinates and make this script working.

CefSharp.WinForms.Example.vshost.exe has exited -1073741819 (0xc0000005) 'Access violation'。

程序“[523076] CefSharp.WinForms.Example.vshost.exe: 程序跟踪”已退出,返回值为 0 (0x0)。
程序“[523076] CefSharp.WinForms.Example.vshost.exe”已退出,返回值为 -1073741819 (0xc0000005) 'Access violation'。
when i run github cef's CefSharp.WinForms.Example Demo, i click item menu "Load Example Extension",the official extension demo "set_page_color" is running ok,but when i add my custom extension,click the item menu "Load Example Extension",then the Program go wrong,it seizing for several seconds,then broke down and exit for the above message.my custom extension works fine in Google Chrome browser,so what went wrong with this ?

Robot Framework: wait until element disappears

I run a test where I have to dismiss a warning that is a DIV that overlays the whole page. First I send a click to a button that adds something, then a warning is displayed. Finally I enter a string in a field
The code looks something like this
SeleniumLibrary.Click element add_button
Wait Until Element is visible warning-overlay-div
SeleniumLibrary.Click element dismiss-warning
SeleniumLibrary.Click element something-else
Running this code results in an error message:
WebDriverException: Message: unknown error: Element <input
type="text" class="upperCaseClass modified" id="something-else"
maxlength="15" style="width: 143px; text-transform: uppercase;"> is
not clickable at point (230, 679). Other element would receive the
click: <div class="warning-overlay-div" style="width: 100%; height:
853px; z-index: 2003;"></div>
That is, I can't click in something-else because warning-overlay-div is on top of it.
Ok, so I added a check to make sure the warning-overlay-div is gone between the the click dismiss-warning and the click on something-else. I have tried multiple variants but these three all give the same result
(from the log)
00:00:15.050KEYWORD SeleniumLibrary . Wait Until Element Is Not Visible ${warning-overlay-div}
00:00:15.003KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain ${warning-overlay-div}
00:00:15.039KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain Element ${warning-overlay-div}
It might take half a second or so for the overlay to disappear but as you can see, all these wait until they timeout after 15 seconds before they return success. I want to continue as soon as the warning-overlay-div is gone, not wait 15 seconds for that.
How do I check that this overlay is gone and then immediately continue?
You could potentially try using "Wait Until Keyword Succeeds" allowing yourself a custom retry timeout. Especially useful if you want to ensure the warning is removed from display in an appropriate amount of time.
Wait Until Keyword Succeeds ${retry} ${retry-interval} Element Should Not Be Visible ${warning-overlay-div}
${retry} = the amount of time overall to perform the check
${retry-interval} = the time between each retry
Time Formats
(I would have made this just a comment but I cannot until I have 50rep - this is just something that might be worth trying)

How to take screenshot in selenium ide

Using Selenium IDE Firefox plugin, I want to take automated screenshots. The test script contains these steps
Command Target Value
open /?gfe_rd=cr&ei=GNCWU-6BCujV8geh_4C4Bg&gws_rd=ssl
click id=gbqfq
type id=gbqfq software testing
click id=gbqfb
captureEntirePageScreenshotAndWait F:\Screenshots\
The log shown this error:-
[error] Unexpected Exception: [Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init]" nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)" location: "JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 2986" data: no]. toString -> function toString() { [native code] }, message -> Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init], result -> 2152857621, name -> NS_ERROR_FILE_ACCESS_DENIED, filename -> chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js, lineNumber -> 2986, columnNumber -> 0, inner -> null, data -> null, location -> JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: <TOP_LEVEL> :: line 2986
please resolve this error
There is a Screenshot on Failure plugin. It grabs a screenshot of the HTML at the point of failure as per it's name. Here is the link:
https://addons.mozilla.org/en-US/firefox/addon/screenshot-on-fail-selenium/
This plugin integrates directly with Selenium so you can turn it on or off through the UI itself. To install it, open the link with a FIREFOX browser and click the "ADD TO FIREFOX" link. (For those not familiar with the Selenium IDE, it only plugs into Firefox.)
Once installed properly you will see a Screenshot on Fail icon next to the "FAST - SLOW" slider. Toggling this button on turns on the feature, toggling it off means that snapshots won't be taken. By default it is off when the IDE is launched. The tiny down-arrow next to it allows you to view the screen shot / failure report(s).

Selenium SelectWindow Command not working

Selenium Select Window command fails and shows "Could not find window with title....". but if i Execute the Select Window command alone it passes the case and verifying the elements.
Code i used:
public void testDefaultlogo() throws Exception {
selenium.open("http://Sitename/samp.aspx");
selenium.type("ctl00_mainContentPlaceHolder_txt_LoginName", "uname");
selenium.type("ctl00_mainContentPlaceHolder_txt_Password", "pwd#12");
selenium.click("ctl00_mainContentPlaceHolder_btn_login");
selenium.waitForPageToLoad("60000");
selenium.click("ctl00_defaultLogo");
selenium.selectWindow("Sample~Window-ID");
verifyEquals("http://Sitename/index.html", selenium.getLocation());
selenium.close();
selenium.selectWindow ("null");
verifyTrue(selenium.isElementPresent("ctl00_defaultLogo"));
I mean by clicking one by one of the follwing commands in Selenium IDE it shows green but if i run the case it failed and shows as i mentioned above
What I can get from your code is that, clicking the "ctl00_defaultLogo" will popup another window. The possible issue could be that after write the command selenium.click("ctl00_defaultLogo") you need to wait for the popup to load.
The possible resolution, insert the command
selenium.WaitForPopUp("Sample~Window-ID", "5000");
before the
selenium.selectWindow("Sample~Window-ID");
This will cause selenium to wait for 5 secs before selecting the popup window.
Hope this helps!!!
some times it may not work for that u better use.
open_window("URL","WindowID or title or name");
selenium.selectWindow("WindowID or title or name");