Access to a pop-up in selenium - selenium

I do have the following code to click a Google button that open a pop-up and then it selects the second Item. It worked fine but now is failing, I guess that due to ID name changed. I do not remember how I Inpectioned the pop-up ID since it does not appears in the "Inpection" Chrome Window.
numOpiniones.click()
self.driver.find_element(By.XPATH,"//button[#data-value='Ordenar']").click()
sleep(random.uniform(1, 1.5))
self.driver.find_element(By.XPATH, "//li[#role='menuitemradio' and #data-index='1']").click()
"menuitemradio" does not exists anymore but I can not see that element in the inspector panel when is created/displayed.
enter image description here

You can use the following css path
driver.find_element(By.CSS_SELECTOR, '#hovercard > #action-menu > [data-index="1"]')

Related

Selenium Webscraping - Print element that is not visible on the site but its on Inspect

enter image description here
I'm trying to print this 91040 from the site but I can't seem to do it and I think the reason is that 91040 is not visible on the site but only on inspect.
element = driver.find_element(By.XPATH,'//div[#class="code-container"]//span[2]')
When I paste this XPATH in the find bar on Inspect it locates the item but when I'm trying to print the element nothing gets printed. I tried these options.
print(element)
print(element.text)
So I'm thinking that the problem is that 91040 is not an actual visible text.
For anyone having the same problem I found the answer
hidden_text = element.get_attribute("textContent")

selenium send key for xpath not working

I want make automation for this web site
in this web site 3 text box are here check image
1st text box x path is /html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]
here is my code
driver.findElement(By.xpath("/html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]")).sendKeys("rio salon");
when I run this code I got this error
Exception in thread "main"
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard
How can i fix it? I hope my xpath is correct.
The field has aria-hidden=true attribute, so you get ElementNotInteractableException. You need to click on the dropdown first to change the attribute to true
WebElement dropdown = driver.findElement(By.xpath("//*[#id='search-form']/div/div[1]/div/div[1]/span"));
dropdown.click();
WebElement textField = dropdown.findElement(By.xpath("./parent::div/following-sibling::input[contains(#class, 'ui-select-search')]"));
textField.sendKeys("rio salon");
You can click in an input field with a div or span tag, but you cannot type in the field. So, your XPath must be written with an input tag if you want to sendkeys or type in an input field. For example:
//input[contains(#placeholder,'Site')]

Tosca: How to scan Dropdown textbox which disapper upon opening xScan

I have a problem in scanning a drop-down menu which disappears upon opening the xScan. I need to get the module id of the dropdown menu to verify some test steps.
Do you have any solution with this if it is not really possible to get the module id of the dropdown menu?
Open developer tools in your browser of choice (F12), navigate to the console and input the following code:
var fulldoc='';
var scrollX=0;
var scrollY=0;
document.addEventListener("keydown",function(event){
if(event.key=='q' && event.altKey){
fulldoc=document.body.outerHTML;
scrollY=window.pageYOffset;
scrollX=window.pageXOffset;
}
if(event.key=='w' && event.altKey){
document.body.outerHTML=fulldoc;
document.body.scrollTo(scrollX,scrollY);
}
});
When the window looks the way you would want to scan, press 'Alt + Q', then press 'Alt + W'.
Now your window will freeze and then you can scan your page.
To steer the objects you need to refresh your browser.
You can resolve the issue with below 2 steps
1 - Add some text in textbox which will populate the dropdown below it .
2 - Use Send Keys Module to scroll down and select the value.
I had a similar issue where we had a popup that only appeared when clicking on a text box. The solution we received from the Tricentis trainer was as follows:
Part One
1. Open your application in Chrome
2. Right click the inspect
3. In the inspector window, on the Elements tab, navigate to your html element where it should be (you can do that by clicking on the element and check that you can see the html in the element)
4. Use the debugger to add a break point there, this should pause it and you should be able to see the elements you need to steer it.
5. Once you found the element, you will need the type of element (e.g. div, span, etc), and the class name
Part two
1. Rescan your module and select any element that matches the criteria of your element selected in Part One #5
2. Identify it by only it's class name property and tag
3. Save and close
4. Edit the element in the module view by changing the class name. This should help you steer it
Note: if the element class name is not unique, you might need to use Explicit name.
Good luck

Window object recognition using RFT on Print Dialogue

Why is RFT not recognizing the objects I have on a windows Print dialog.Included are few screen shots.
I am able to get the correct activeWIndow by
TestObject[] to ;
IWindow activeWindow = RationalTestScript.getScreen().getActiveWindow();
System.out.println("Class of active window is "+activeWindow.getCLass()): // returns #32770
ScreenTestObject root = RootTestObject.getScreenTestObject();
to = root.find(atLIst(atDescendant(".class", false),atChild(".class", ".Pushbutton", ".text", "Print"))) ;
Apparantly I can't post pictures. here is the link for print window and print button properties screenshot
http://www.flickr.com/photos/24358027#N07/12977082214/in/set-72157641973533994
...resolutions is horrible, I can type all the information if anyone needs it. Sorry and Thanks in advance.
Try The below Code snippet. I tried launching the print dialog from notepad and ran below script to find the print button and click it.Hope it helps.
//Find the Print button
TestObject[] to = find(atDescendant(".class",".Pushbutton",".text","Print"),true);
System.out.println(to.length);
//If you are sure you have just one print button on screen.
if(to.length==1)
((GuiTestObject) to[0]).click();
//Else traverse through the found object and compare the properties of the button you want to click
Update : I did a workaround for this, using tab to navigate. Once Tab is on the button, I input Enter. So it's not a work stoppage issue anymore, but I do need to figure out the right way to do it.
Thanks

seleniumIDE - how to store a hyperlinks address and then visit that URL? Was working before

I had this working fine a couple of months ago but now when I run the test it fails and I don't know why or how to fix.
Background:
I have a screen with several links so that the 'admin' user who is currently logged in can login as one of the 'practitioners' via the login hyperlink presented.
Details:
So for my test I click on the 'Login link' hyperlink(s), enter & confirm a new password as required, and then I get to the practitioners screen 'as them'. The 'wrinkle' was that the pop-up for the user to enter their (new) password happened on a new window that the selenium IDE used was a new window. So basically just clicking on the hyperlink didn't work. To get around this I was able to store the hyperlink's href -a#href- in a selenium variable first_login_link_to and then use open instead of clickAndWait to visit the page, i.e. open ${first_login_link_to}
This was working fine a few months ago.... but it is not working now.
I get page doesn't exist and when I look at the url - urgh! It somehow includes the locator stuff and I am getting
http://dmplanning-stage.herokuapp.com//tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
instead of
http://dmplanning-stage.herokuapp.com/p/zaH7m3aL7fxuPLvrc21L
in the browsers url address bar.
How can I get selenium to open the url stored in the variable and not use that 'locator' address?
selenium:
open /admin
clickAndWait link=practitioners
store //tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
open ${first_login_link_to}
Found it - whew! Somehow my storeAttribute got changed to plain store.
Once I changed it back everything worked again!
This one worked for me
1-
Command = Store
Target = stuff you want to paste
Value = Var
2-
Command = sendkeys
Target = id for area where u wana paste
Value = ${Var}
3-
Command = Fireevent
Target = id for area where u wanna paste
Value = paste