How to create an XPATH for the dynamically changing properties - xpath

When users logs in , I can see the below html source. I'm trying to implement click operation for the "Change Password" link using Webdriver in C#.
When user 1 Login , the below sample code generates for change password link:
<td> <img src="/u/default/img/global/change_password.gif;jsessionid=xxxxxxxEA57DB0A9F754B53A6E" width="92" height="15" alt="Change Password" border="0"></td>
When user 2 Login , the below sample code generates for change password link:
Change Password

You can you OR in xpath so that any user xpath will work:
//img[#alt='Change Password']|//a[contains(text(),'Change Password')]

Related

Using codeigniter 4, cannot send link in gmail

$message = "Hi ".$name.", <br>Your account is created successfully. Please click the below link to activate your account
<br><br><a href=".base_url()."/register/activate/".$uniid."Activate now </a>";
I already recieved the email but the href function is excluded. it only display
"Hi myname,
Your account is created successfully. Please click the below link to activate your account";
it dont display the link
You have syntax errors in your code.
Missing > in anchor tag".$uniid."Activate now
Wrong href dicleration href=".base_url()."/register/activate/".$uniid."
wrap inner conditions with '.
Use below code
$message = "Hi {$name}, <br>Your account is created successfully. Please click the below link to activate your account
<br><br><a href='/register/activate/{$uniid}'>Activate now </a>";

Automation using Watir button elements

So I have been experimenting with Watir automation scripts using Ruby. I have tried to experiment with different websites, like Twitter, Gmail, and Yahoo. Here is the catch: I am able to open a browser, login, and get to the home page. On all of these whether it is compose a new email or tweet every time I select it with the appropriate ID or Class, it throws an error in the terminal like this...
.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:533:in assert_element_found': unable to locate element, using {:title=>"compose", :tag_name=>"button"} (Watir::Exception::UnknownObjectException)
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:505:inassert_exists'
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:114:in click'
from yahoo_mail.rb:18:incompose_email'
from yahoo_mail.rb:27:in `'
My question is, are there elements that you simply cannot click or select using Watir automation?
EDIT: How would I be able to hit this to be more specific? I seem to be getting the same results on Yahoo, Gmail, and Twitter when it comes to composing anything after getting logged in. So I how would I hit this button?
button id="global-new-tweet-button" type="button" class="js-global-new-tweet js-tooltip btn primary-btn tweet-btn js-dynamic-tooltip" data-placement="bottom" data-component-term="new_tweet_button">
The HTML for the Compose button is basically the following (NOTE: id attribute removed):
<button tabindex="0" data-action="compose" title="Compose" class="btn btn-compose">
Your stacktrace indicates that you're using this locator:
{:title=>"compose", :tag_name=>"button"}
If you change :title=>"compose" to :title=>"Compose", you should be in business.
Have you tried the following code?
button(id:'global-new-tweet-button').when_present.click
Maybe you were clicking the button without checking if it is already present on the page.

liferay force theme refresh

I have created theme. In this, If user logs in then he got to see his name , image etc above header.
It also contains edit profile link which redirects to page where I have placed 'Edit User' portlet. This is my custom portlet.
For showing user details in theme I have used code as:
<span>Welcome </span>
<span class="userName">$user_name</span>
<img alt="image" src="$user.getPortraitURL($themeDisplay)"/>
Edit Profile
Logout
Edit user is a spring portlet, I have used action request for updating the user.
liferayUser = UserLocalServiceUtil.getUser(themeDisplay.getUserId());
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String email = request.getParameter("email");
if(liferayUser != null)
{
liferayUser.setFirstName(firstName);
liferayUser.setLastName(lastName);
liferayUser.setEmailAddress(email);
liferayUser.setModifiedDate(new Date());
liferayUser = UserLocalServiceUtil.updateUser(liferayUser);
logger.error(":::LR User updated:::"); }
My page is getting refreshed, user is getting updated I can able to see response on text box. But I can not able to see the changed value in the theme.
For getting the value, I have to refresh the page. In short $user_name is not getting updated value over my action. As I can able to see same name in liferay's accordion.
Is there any way to reload the theme on any action in the portlet.
I am using liferay 6.2 version.
Thanks in Advance

How can I inspect the values of tags during the submit of a form using Chrome Dev Tools?

During a page's "dormant" state, I can inspect the values of any tag by entering its id in Chrome Dev Tools' console tab, like so, e.g. for a tag with the name "BeginDate":
0) Enter "BeginDate" in the console tab
1) Mash the key
...and I see the whole shebang:
<input alt="date-us" data-val="true" data-val-regex="End Date must be in the format &quot;m/d/yyyy&quot;" data-val-regex-pattern="[0-9]*[0-9]/[0-9]*[0-9]/[0-9]{4}" data-val-required="End Date must be in the format &quot;m/d/yyyy&quot;" id="EndDate" name="EndDate" style="width: 164px;" type="text" value="5/14/2013" class="hasDatepicker">
So it shows the value, which is the part I'm interested in, is today's date.
What I want to inspect, though, is just what is being passed/posted when the form's Submit button is pressed; I believe this would be, in asp.net, the contents of the Request object, but how can I see these vals using Chrome Dev Tools?
I right-clicked in the console and selected "Log XMLHTTPRequests" and "Preserve log upon navigation" but...are they logged? If so, where are they? I see nothing in the Console tab...
UPDATE
Thanks to David Ziemann, here's what I see:
The Network tab will show you any network communication. Within that you can select the request and view the headers which should include the form data.

Disabling developer mode or debugging feature in openerp?

How can I disable the debugging mode or developer mode for users other than admin? I tried to remove the button 'Activate developer mode', but the problem was, if I add '?debug' after the server address in the address bar, then again the user gets the developer mode.
Following code will disable debug mode (Drop-down box) if user is admin (admin ID must be 1. If not then change session.uid === admin_id):
Create one xml file inside your_module/static/src/xml folder and add following code:
<templates>
<t t-extend="ViewManagerAction">
<t t-jquery="select.oe_debug_view" t-operation="replace">
<select t-if="widget.session.uid === 1 and widget.session.debug" class="oe_debug_view"/>
</t>
</t>
</templates>
Now go to __openerp__.py and add your xml like this:
'qweb' : [
"static/src/xml/your.xml",
],
Restart server, update your module and refresh the page.
You can refer this blog: OpenERP Web Changes.
You tried with logout.
default is its remove when we log off.

Resources