I am trying to use selinum for chrome with Salesforce to search the salesforce for case number.
I am able to login and write the case number in the salesforce search box, but I am not able to retrieve the output.
My code:
# create a new Chrome session
driver = webdriver.Chrome(chrome_driver_path)
driver.implicitly_wait(300)
driver.maximize_window()
# Navigate to the application home page
driver.get("https://salesforce.com/xxx")
driver.implicitly_wait(100)
search_field = driver.find_element_by_xpath("//input[#title='Search Salesforce']")
search_field.click();
search_field.clear();
search_field.send_keys("case number").wait();
driver.find_element_by_xpath("//span[#title='case number']");
search_field.click();
driver.implicitly_wait(10)
search_field.submit();
search_field.sendKeys(Keys.RETURN);
Since I am not able to make comments due to lack of reputation points, this is what I wanted to add to #RockinWatson's response above:
There is a chance that the 'value' attribute does not get updated after you enter value in search field. In that case, either
click somewhere outside of the box
or hit tab using search_field.sendKeys(Keys.TAB);
or hit enter using search_field.sendKeys(Keys.RETURN); as long as it doesn't take you away from the page.
You will have to get the value Attribute from the element after entering the text.
input_text = search_field.get_attribute("value")
Related
I have a website (private, sorry) that I'm trying to log into automatically but the login page has no source code available so am unable to assign/find specific elements.
The cursor is blinking on the Username input field, so trying somehow to start typing then tab to password field and then enter.
I've tried the following three different methods, neither fills in any text.
ActionChains:
actions = ActionChains(driver)
actions.send_keys("*username*")
actions.perform()
Passing info to the url itself:
driver.get("https://username:password#my_website.com")
By active element:
active_ele = driver.switch_to.active_element
active_ele.send_keys("test")
I'm guessing your target page is protected by Basic Authentication, and what you're calling the "login page" is not an actual "page", but rather the browser's Basic Authentication dialog box. This "pop-up box" is not an actual page element, so you can't manipulate it with Selenium's page-element API.
In my own Selenium code, with current Chrome (version 90), the "https://username:password#my_website.com" URL does actually work to open the target page. However, it doesn't "fill in any text" like you said; it just directly opens the protected page. Also, a "https://username:password#my_website.com" URL doesn't work in the browser address bar itself; it only works in the Selenium API. Also, my tests are in C#; FAIK the "https://username:password#my_website.com" technique might not work in Python.
Note, Chrome removed the "https://username:password#my_website.com" feature for years, but then they brought it back, sometime before November 2019, when I discovered it; but they only brought it back for the Selenium API, not for the browser address bar.
Not able to click x or continue to flights
Here is the url: https://www.kayak.com/flights/ORD-JFK/2020-09-13/2020-09-20?sort=bestflight_a
using css = '.Button-No-Standard-Style.close-button'
I was using the following to find and click it:
driver.find_element_by_css_selector('.Button-No-Standard-Style.close-button').click()
What I found out was the button had dynamic ID. I had to click the button based on partial ID comparison.
I used:
cl_bt = driver.find_element_by_xpath("//*[contains(#id, 'covid-loading-dialog-close')]")
where 'covid-loading-dialog-close' was the part of the ID that was not changing.
I'm trying to write program, that logins to my e-mail account and sends the mail to the provided recipient. For that I' using selenium.
The problem I'm meeting, that I can't find the correct id or class of the message content block, so the email which I send is empty.
My code's fragment:
try:
bodyElem = browser.find_element_by_id('eml-cke__body')
bodyElem.send_keys('Some text to send to a recipient')
except:
print('Was not able to find an element with that name.')
I'm using browser inspector, and when I hover on the content box, I get info provided in an image bellow:
But when I try to find given element the program finds nothing, so text isn't added.
I want to know what I'm doing wrong when searching for the right id or class for that field and how I can do it correctly.
The Page Source of "compose message window"
you can use send_keys only for input tags
I am trying to check my check box in Geb.
I have tried following codes, but no luck
$('input', type:'checkbox', id: 'chkTermsConditions', tabindex: '-1').value('true')
$(".CheckBoxUI").value('true')
Following is the HTML
After mouse go over the check box additional text updated (marked in the screen shot)
You are attempting to check the box which has the attribute with value='true'
From the Geb manual:
The value of input, select and textarea elements can be retrieved and set with the value method. Calling value() with no arguments will return the String value of the first element in the Navigator. Calling value(value) will set the current value of all elements in the Navigator. The argument can be of any type and will be coerced to a String if necessary. The exceptions are that when setting a checkbox value the method expects a boolean (or, an existing checkbox value) and when setting a multiple select the method expects an array or Collection of values.
Try this:
$("#chkTermsConditions").value(true)
If you are using non standard HTML generated by some other platform. You may have to resort to clicking the element or using javascript.
The element that produces the desired click result could be one of the surrounding elements. If the widget is javascript controlled you may have to call a function that is embedded into the page for that widget. If its a javascript widget I cannot help you unless you can point me to a page which uses the same platform.
Try:
$('a[class=CheckRadioFocus]').click()
$('a[id=termLink]').click()
or any of the other surrounding elements.
I managed to check the check box with $(".CheckBoxStyle").click()
Only issue is still Submit button doesn't get enable. Following is the html code for before and after checking the check box in real situation.
I tried the to click on the submit button with following code. It doesn't give any error. But still doesn't move to next page as expected.May be because of Submit button disable issue.
$("#submitBtnMsg").click()
Edited :
It was turned out above was application related issue. We have to click on the address after selecting via address validation service. Then only Submit button get enable.
$(".RedColor").click()
I am trying to work with mouseover on a particular Item in my application by using the following command
{
ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
}
On doing mouseover on a item, two subitems are displayed.
Is there any way to capture the sub items which are part of the Item by doing mouseover with which we can report that our test is pass or fail.
Please suggest.
Additional Information :
If we take example,On the StackOver flow page, If i do mouseover on my name, i get a window where i see activity, privileges, Logout and other stuff. This is really what i was looking for. Is there a way to capture the items displayed on the window on doing mouseover.
I also tried to capture the subitems with the following :
{
text=ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
puts(text.inspect)
}
On doing this "text" value is displayed as 'nil'.
My general tactic for such things is a combination of using IRB and the IE Developer tool, or Firebug.
using IRB, type out (or cut and paste) the watir statement to fire the onmouseover command to the proper element on the page.
Then have the developer tool rescan the DOM (there's a little refresh icon you can click) The use the tool to point to an element to point to one of the items in the stuff exposed by the onmouseover. Using the info from that, you can then figure out how to address those elements to get the text from the proper div, etc.
If I do that here to the info that opens up when I float the mouse over my name I can find out that it is a table of class "profile-recent-summary" Furthermore I can then look at the way the table is made up and see for example that the 'today' reputation value is in the second cell on that row.. The row also has the text 'reputation' in it.. so
browser.table(:class, 'profile-recent-summary').row(:text, /reputation/).cell(:index, 2).flash
Should flash the cell I want (index might be 1 if using firewatir or webdriver) I can then replace the .flash with something else like .text if I want to get the text from that cell (which is actually inside a link that sits in the cell)..
without seeing your code, I would 'inspect' the element that you are trying to verify and when_present (text) assert that its true